/* ============================================================
   Project EVA-SURVIVOR — 카툰 UI 스타일
   ============================================================ */
/* Galmuri — 비트맵 한글 폰트 (SIL OFL 1.1, (c) Lee Minseo / quiple)
   크기별 전용 글리프: Galmuri9=9px, Galmuri11=11px(및 22px), Galmuri14=14px(및 28px)에서 픽셀 정렬 */
@font-face { font-family: 'Galmuri11'; font-weight: 400; font-display: swap;
  src: url('../assets/fonts/Galmuri11.woff2') format('woff2'); }
/* 주의: Galmuri11-Bold는 로드되나 11px에서 픽셀 정렬이 깨져 스무스하게 렌더됨 — bold 대신 컬러/배경으로 강조할 것 */
@font-face { font-family: 'Galmuri11'; font-weight: 700; font-display: swap;
  src: url('../assets/fonts/Galmuri11-Bold.woff2') format('woff2'); }
@font-face { font-family: 'Galmuri14'; font-weight: 400; font-display: swap;
  src: url('../assets/fonts/Galmuri14.woff2') format('woff2'); }
@font-face { font-family: 'Galmuri9'; font-weight: 400; font-display: swap;
  src: url('../assets/fonts/Galmuri9.woff2') format('woff2'); }

:root {
  /* MAGI 터미널 문법 — 하드엣지·단색·인광 팔레트 (보급 의결기 문법을 전체 UI로 확장) */
  --ink: #060805;
  --panel: #12160d;
  --panel2: #1b2214;
  --line: #3a4224;
  --line2: #232812;
  --cream: #d6e4c8;
  --dim: #7d948a;
  --orange: #ffb03a;
  --yellow: #ffe23c;
  --green: #57ff9e;
  --red: #ff5040;
  --cyan: #7ff0ff;
  --purple: #a06cff;
}
@font-face { font-family: 'Press Start 2P'; font-weight: 400; font-display: block;
  src: url('../assets/fonts/PressStart2P.woff2') format('woff2'); } /* v0.2.19 자체 호스팅 — 구글폰츠 지연/차단 시 폴백 폰트로 렌더돼 메트릭이 흔들리는 문제 차단. display:block이라 로드 전엔 숨김(폴백 메트릭 오염 방지) */
/* v0.2.29 — 캔버스 스프라이트용 라틴 서브셋 자체 호스팅 (구글폰츠 의존 완전 제거). 라틴+숫자만 포함해 23/34KB로 경량 */
@font-face { font-family: 'Black Han Sans'; font-weight: 400; font-display: swap;
  src: url('../assets/fonts/BlackHanSans.woff2') format('woff2'); }
@font-face { font-family: 'Jua'; font-weight: 400; font-display: swap;
  src: url('../assets/fonts/Jua.woff2') format('woff2'); }

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
html, body { width: 100%; height: 100%; overflow: hidden; background: #0a0d06; overscroll-behavior: none; }
body { font-family: 'Galmuri11', 'Malgun Gothic', sans-serif; color: var(--cream); user-select: none; }
#game canvas { display: block; touch-action: none; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
.hidden { display: none !important; }
button { font-family: inherit; cursor: pointer; }

/* ---------- 공통 카툰 부품 ---------- */
.cartoon-btn {
  display: inline-block; border: 2px solid var(--ink); border-radius: 0;
  background: linear-gradient(180deg, #ffd88a 0 50%, var(--orange) 50%); /* 2단 플랫 셰이딩 — 광택 아님 */
  color: #201604; font-family: 'Galmuri14', 'Galmuri11', sans-serif; font-size: 14px; padding: 8px 14px; letter-spacing: 1px;
  box-shadow: 3px 3px 0 rgba(0, 0, 0, .55); transition: transform .08s, box-shadow .08s;
}
.cartoon-btn:hover { filter: brightness(1.12); }
.cartoon-btn:active { transform: translate(2px, 2px); box-shadow: 1px 1px 0 rgba(0, 0, 0, .55); }
.cartoon-btn.cool { background: linear-gradient(180deg, #a5f2c8 0 50%, #3cd485 50%); color: #06210f; }
.cartoon-btn.danger { background: linear-gradient(180deg, #ff9d8a 0 50%, #ff5040 50%); color: #2a0703; }
.cartoon-btn.ghost { background: linear-gradient(180deg, #27311d 0 50%, #1a2213 50%); color: var(--green); border-color: var(--line); }
.panel {
  background: var(--panel);
  border: 3px solid var(--ink); border-radius: 0;
  box-shadow: 5px 5px 0 rgba(0, 0, 0, .5), inset 0 0 0 2px var(--line2);
}
.tag {
  display: inline-block; font-size: 11px; letter-spacing: 1px; color: var(--ink);
  background: var(--yellow); border: 2px solid var(--ink); border-radius: 0; padding: 1px 8px;
  text-shadow: none; /* 부모의 text-shadow 상속으로 글자가 이중으로 보이는 것 방지 */
}
.bar { position: relative; height: 17px; border: 2px solid var(--ink); border-radius: 0; background: #080a05; overflow: hidden; }
.bar-tag {
  position: absolute; left: 5px; top: 0; bottom: 0; z-index: 2;
  display: flex; align-items: center; transform: translateY(.5px); /* v0.2.21 — 수치(.txt)와 동일한 플렉스 중앙정렬+보정으로 통일, 라벨·숫자 높이 일치 */
  font-family: 'Galmuri9', 'Press Start 2P', monospace; font-size: 9px;
  letter-spacing: .5px; color: rgba(255, 255, 255, .95); text-shadow: 1px 1px 0 #000;
  pointer-events: none;
}
.bar .fill { height: 100%; width: 50%; transition: width .18s; }
.bar .txt {
  position: absolute; inset: 0; font-family: 'Galmuri11', 'Press Start 2P', monospace; /* v0.2.22 — PS2P는 8px 배수가 아닌 소형에서 안티에일리어싱으로 번져 픽셀감 소실, Galmuri9은 9px 네이티브 비트맵이라 선명 */
  font-size: 11px; line-height: 1; letter-spacing: 1px;
  display: flex; align-items: center; justify-content: center; /* v0.2.19 — line-height 트릭 대신 플렉스 중앙정렬: 모바일의 얕은 바(내부 6~7px)에서 글리프 하단이 잘리며 위로 붙던 문제 해결, 실측 오차 0 */
  transform: translateY(.5px); /* v0.2.20 — 잔여 잉크 편향(-0.5px, 폰트 메트릭) 실측 보정 */
  color: #fff; text-shadow: 1px 1px 0 #000;
}
.fill.hp { background: linear-gradient(180deg, rgba(255,255,255,.2) 0 40%, transparent 40%), #e8324a; }
.fill.atf { background: linear-gradient(180deg, rgba(255,255,255,.2) 0 40%, transparent 40%), #3f9fe0; }
.fill.sync { background: linear-gradient(180deg, rgba(255,255,255,.2) 0 40%, transparent 40%), #f0a41f; }
.fill.ok { background: linear-gradient(180deg, rgba(255,255,255,.2) 0 40%, transparent 40%), #2cc75a; }
.fill.warn { background: linear-gradient(180deg, rgba(255,255,255,.2) 0 40%, transparent 40%), #f0a41f; }
.fill.danger { background: linear-gradient(180deg, rgba(255,255,255,.2) 0 40%, transparent 40%), #ee3020; animation: blink .5s infinite alternate; }
@keyframes blink { to { filter: brightness(1.5); } }

/* ---------- HUD ---------- */
#hud { position: fixed; inset: 0; pointer-events: none; z-index: 20; display: flex; flex-direction: column; justify-content: space-between;
  padding: max(10px, env(safe-area-inset-top)) max(10px, env(safe-area-inset-right)) max(10px, env(safe-area-inset-bottom)) max(10px, env(safe-area-inset-left)); }
#hud-top { display: grid; grid-template-columns: minmax(230px, 300px) 1fr minmax(220px, 280px); gap: 10px; align-items: start; }
#hud-bottom { display: flex; justify-content: space-between; align-items: flex-end; gap: 10px; }
.hud-panel { pointer-events: auto; padding: 10px 12px; }
.hud-panel h3 { font-size: 11px; color: var(--yellow); letter-spacing: 1px; margin-bottom: 6px; display: flex; justify-content: space-between; align-items: center; }
#unit-name { font-size: 22px; font-family: 'Galmuri11', sans-serif; color: #fff; text-shadow: 2px 2px 0 #000; letter-spacing: 1px; }
#pilot-name { font-size: 11px; color: var(--dim); margin-bottom: 6px; }
#map-name { font-size: 11px; color: var(--green); }
.hud-panel .bar { margin-top: 5px; }
#level-text { font-family: 'Galmuri9', 'Press Start 2P', 'Galmuri11', monospace; font-size: 9px; color: var(--yellow); letter-spacing: 1px; }
#clock { font-size: 24px; font-family: 'Press Start 2P', 'Galmuri11', monospace; color: var(--green); text-shadow: 2.5px 2.5px 0 #000; text-align: center; letter-spacing: 2px; }
#kill-count { text-align: center; font-family: 'Galmuri14', 'Galmuri11', sans-serif; font-size: 14px; color: var(--dim); margin-top: 2px; }
#cable-state { font-family: 'Galmuri14', 'Galmuri11', sans-serif; font-size: 14px; padding: 2px 8px; border: 2px solid var(--ink); display: inline-block; margin-top: 4px; letter-spacing: 1px; }
#cable-state.ok { background: #10301c; color: var(--green); border-color: #1d5a34; }
#cable-state.danger { background: #381010; color: #ff8060; border-color: #6a2018; animation: blink .5s infinite alternate; }
#weapon-list { display: flex; flex-direction: column; gap: 4px; margin-top: 6px; }
.weapon-chip { font-size: 11px; padding: 3px 9px; border: 2px solid var(--line); background: #1a2213; color: var(--cream); }
.weapon-chip b { font-size: 10px; padding: 0 5px; background: var(--ink); color: var(--yellow); margin-right: 4px; }
.weapon-chip i { font-style: normal; color: var(--green); font-family: 'Galmuri9', 'Press Start 2P', 'Galmuri11', monospace; font-size: 9px; }
.weapon-chip.slot-melee { border-color: #39e06a; }
.weapon-chip.slot-ranged { border-color: #ffb03a; }
.weapon-chip.slot-defense { border-color: #7ff0ff; }
.weapon-chip.slot-boss { border-color: #ff3b4d; }
#hud-mid { display: flex; flex-direction: column; align-items: center; gap: 8px; }
#boss-hud { width: min(460px, 90%); padding: 8px 14px; }
#boss-name { font-family: 'Galmuri14', 'Galmuri11', sans-serif; font-size: 14px; color: #ffb8b8; text-align: center; display: block; margin-bottom: 4px; }
#boss-bar .fill { background: linear-gradient(180deg, rgba(255,255,255,.2) 0 40%, transparent 40%), #e84a20; }
#alert-banner {
  font-family: 'Galmuri11', sans-serif; font-size: clamp(18px, 3.2vw, 30px); letter-spacing: 2px;
  color: #fff; padding: 8px 26px; border: 3px solid var(--ink);
  background: repeating-linear-gradient(45deg, #d92e20 0 22px, #8a1408 22px 44px);
  box-shadow: 5px 5px 0 rgba(0, 0, 0, .5); text-shadow: 2.5px 2.5px 0 #000;
  animation: alertIn .35s cubic-bezier(.2, 1.6, .4, 1);
}
@keyframes alertIn { from { transform: scale(.3) rotate(-6deg); opacity: 0; } }
#sys-log { font-size: 11px; color: var(--dim); background: rgba(10, 12, 5, .85); border: 2px solid var(--line2); padding: 3px 12px; }
.hud-right { text-align: right; }
.hud-sub { font-size: 10px; color: var(--dim); font-weight: 400; letter-spacing: .5px; }
.hud-btns { display: flex; gap: 6px; justify-content: flex-end; margin-top: 8px; flex-wrap: wrap; }
.hud-btns .cartoon-btn { font-family: 'Galmuri11', sans-serif; font-size: 11px; padding: 5px 10px; }

/* 디버그 */
#debug-buttons { display: none; }

/* 조이스틱 */
#joystick { position: fixed; width: 136px; height: 136px; margin: -68px 0 0 -68px; border-radius: 50%; border: 4px solid rgba(255, 148, 53, .85); background: rgba(255, 148, 53, .15); box-shadow: 0 0 18px rgba(255, 148, 53, .35), inset 0 0 26px rgba(255, 148, 53, .18); z-index: 30; pointer-events: none; }
#joystick::after { content: ''; position: absolute; left: 50%; top: 50%; width: 10px; height: 10px; margin: -5px; border-radius: 50%; background: rgba(255, 148, 53, .7); }
#joy-knob { position: absolute; left: 50%; top: 50%; width: 52px; height: 52px; margin: -26px 0 0 -26px; border-radius: 50%; border: 3px solid var(--ink); background: #39e06a; box-shadow: inset -6px -6px 0 rgba(0, 0, 0, .25); }

/* ---------- 타이틀 ---------- */
/* margin:auto 패턴: 내용이 화면보다 크면 위쪽이 잘리는 justify/align:center 버그 방지 */
.overlay { position: fixed; inset: 0; z-index: 40; display: flex; overflow-y: auto; }
.overlay > * { margin: auto; }
#title-screen { background: radial-gradient(ellipse at 50% 30%, #3d3463 0%, #1a1428 65%, #0d0a18 100%); }
/* ---------- 타이틀 픽셀아트 스킨 — 도트 폰트 + 각진 카드 ---------- */
#title-screen { font-family: 'Galmuri11', 'Jua', sans-serif; }
#title-logo .kr { font-family: 'Press Start 2P', 'Galmuri11', sans-serif; }
.section-label, .map-card .mc-name, .map-card .mc-sub, .mc-diff, .mc-boss,
.unit-card .uc-band, .unit-card .uc-pilot, .unit-card .uc-desc, .unit-card .uc-weapon,
#callsign, #callsign-row .tag, #title-screen .cartoon-btn, #copyright, #visit-row { font-family: 'Galmuri11', 'Jua', sans-serif; }
.unit-card .uc-band { border-radius: 0; }
#title-inner { text-align: center; padding: 18px 14px 30px; max-width: min(1600px, 96vw); width: 100%; min-width: 0; margin: 0 auto; display: flex; flex-direction: column; min-height: 100vh; }
@media (min-height: 1150px) { #title-inner { justify-content: safe center; } } /* safe: 콘텐츠가 넘치면 상단 정렬로 폴백 — 로고 잘림 방지 */
#title-logo { position: relative; margin-bottom: 4px; }
#title-logo .kr {
  font-family: 'Press Start 2P', 'Galmuri11', sans-serif; font-size: clamp(34px, 6.5vw, 68px);
  color: #fff; letter-spacing: 2px;
  text-shadow: 4px 4px 0 var(--ink), 8px 8px 0 rgba(0, 0, 0, .35);
}
#title-screen::after { content: ''; position: fixed; inset: 0; z-index: 40; pointer-events: none;
  background: repeating-linear-gradient(0deg, rgba(0, 0, 0, .06) 0 1px, transparent 1px 4px);
  box-shadow: inset 0 0 150px rgba(0, 0, 0, .45); }
.map-card, .unit-card {
  clip-path: polygon(10px 0, calc(100% - 10px) 0, 100% 10px, 100% calc(100% - 10px), calc(100% - 10px) 100%, 10px 100%, 0 calc(100% - 10px), 0 10px);
  filter: drop-shadow(6px 6px 0 rgba(0, 0, 0, .5));
}
.map-card:hover, .unit-card:hover { filter: drop-shadow(9px 9px 0 rgba(0, 0, 0, .5)); }
#title-logo .kr em { font-style: normal; color: var(--purple); }
#title-logo .kr em:nth-of-type(2) { color: var(--green); }
#title-logo .sub { font-size: clamp(12px, 2vw, 16px); color: var(--yellow); letter-spacing: 3px; margin-top: 2px; }
#title-logo .stripe { height: 8px; margin: 10px auto 0; width: min(520px, 80%); border: 3px solid var(--ink); border-radius: 0; background: repeating-linear-gradient(90deg, var(--orange) 0 16px, var(--ink) 16px 32px, var(--purple) 32px 48px, var(--ink) 48px 64px, var(--cyan) 64px 80px, var(--ink) 80px 96px); }
/* 섹션 라벨 — 좌우 페이드 구분선이 붙는 디바이더 */
.section-label {
  display: flex; align-items: center; justify-content: center; gap: 14px;
  font-family: 'Galmuri14', 'Galmuri11', sans-serif; font-size: 14px; color: var(--cyan); margin: 26px 0 12px; letter-spacing: 2px;
}
.section-label::before, .section-label::after {
  content: ''; flex: 1; max-width: 230px; height: 4px; border-radius: 0;
  background: repeating-linear-gradient(90deg, rgba(127, 240, 255, .55) 0 8px, transparent 8px 18px);
}
.section-label::after { transform: scaleX(-1); }
#map-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; }
.map-card {
  padding: 14px 14px 16px; cursor: pointer; text-align: center;
  transition: transform .12s, box-shadow .12s; position: relative;
}
.map-card:hover { transform: translateY(-4px); }
.map-card img { width: 100%; height: clamp(140px, 21vh, 210px); object-fit: cover; border: 2px solid var(--line); border-radius: 0; display: block; image-rendering: pixelated; background: #0d0a18; }
.map-card .mc-name { font-size: 22px; margin-top: 9px; color: #fff; }
.map-card .mc-sub { font-size: 11px; color: #cfc6ee; margin-top: 2px; }
#yt-pick { width: 100%; padding: 9px 10px; background: #0a0e06; color: var(--green); border: 2px solid var(--line); border-radius: 0; font-family: inherit; font-size: 11px; }
.mc-diff { display: inline-block; font-size: 10px; padding: 1px 8px; border: 2px solid var(--ink); vertical-align: 2px; margin-left: 4px; }
.diff-easy { background: var(--green); color: var(--ink); }
.diff-norm { background: var(--yellow); color: var(--ink); }
.diff-hard { background: var(--red); color: #fff; }
.mc-boss {
  display: inline-block; font-size: 11px; color: var(--orange); margin-top: 7px;
  background: rgba(255, 176, 58, .1); border: 1px solid rgba(255, 176, 58, .3); padding: 2px 9px;
}
.map-card.sel { outline: 4px solid var(--green); box-shadow: 0 0 0 4px var(--ink), 8px 8px 0 rgba(0, 0, 0, .45); }
.map-card.sel::after { content: '✔ 선택됨'; position: absolute; top: 8px; right: 8px; background: var(--green); color: #06210f; font-size: 11px; padding: 2px 8px; border: 2px solid var(--ink); }
#unit-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.unit-card { padding: 0; overflow: hidden; cursor: pointer; text-align: left; transition: transform .12s; }
.unit-card:hover { transform: translateY(-4px) scale(1.02); }
.unit-card .uc-band { padding: 8px 12px; border-bottom: 3px solid var(--ink); font-family: 'Galmuri11', 'Jua', sans-serif; font-size: 17px; color: #fff; text-shadow: 2px 2px 0 var(--ink); display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 2px 6px; }
.unit-card .uc-band .tag { font-family: 'Galmuri11', 'Jua', sans-serif; font-size: 11px; flex-shrink: 0; white-space: nowrap; }
.unit-card .uc-body { display: flex; gap: 12px; padding: 12px 14px; }
.unit-card canvas { width: 96px; height: 106px; image-rendering: pixelated; border: 2px solid var(--line); border-radius: 0; background: #0d130d; flex-shrink: 0; }
.unit-card .uc-pilot { font-size: 11px; color: var(--yellow); }
.unit-card .uc-desc { font-size: 11px; line-height: 1.45; color: #a8bfa8; margin-top: 3px; }
.unit-card .uc-weapon { font-size: 11px; color: var(--cyan); margin-top: 5px; }
/* 파일럿 이름 입력 — 맵 선택과 기체 선택 사이 단독 행 */
#callsign-row { margin: 0 0 2px; display: flex; gap: 8px; justify-content: center; align-items: center; flex-wrap: wrap; }
#callsign {
  font-family: inherit; font-size: 16px; padding: 8px 14px; flex: 1; width: auto; max-width: 560px; min-width: 180px;
  border: 2px solid var(--line); background: #0a0e06; color: var(--green); text-align: center; letter-spacing: 1px;
}
#callsign:focus { outline: 2px solid var(--green); outline-offset: 1px; }
#rank-overlay { background: rgba(13, 10, 24, .82); z-index: 49; }
#rank-box { max-width: 640px; width: min(640px, 95vw); padding: 14px 18px; }
#rank-box h3 { font-family: 'Galmuri14', 'Galmuri11', sans-serif; font-size: 14px; font-weight: 400; color: var(--yellow); margin-bottom: 8px; padding-bottom: 7px; border-bottom: 2px solid var(--ink); display: flex; justify-content: space-between; align-items: baseline; }
#rank-status { font-size: 10px; color: #9d93c4; font-weight: 400; }
table.score { width: 100%; border-collapse: collapse; font-size: 11px; }
table.score th { color: var(--cyan); font-size: 11px; padding: 4px 4px; border-bottom: 2px solid var(--ink); letter-spacing: 1px; }
table.score td { padding: 4px; border-bottom: 1px dashed rgba(255, 255, 255, .12); text-align: center; }
table.score tbody tr:hover td { background: rgba(255, 255, 255, .05); }
table.score tr.me td { color: var(--yellow); background: rgba(255, 226, 60, .07); }
table.score td.empty { color: #9d93c4; padding: 4px; }
/* 랭킹판 결과 필터 — 전체/성공/실패 */
#rank-filters { display: flex; gap: 6px; margin-bottom: 8px; }
#rank-filters .cartoon-btn { font-family: 'Galmuri11', sans-serif; font-size: 11px; padding: 5px 16px; flex: 0 0 auto; }
#rank-filters .cartoon-btn.on { background: linear-gradient(180deg, #ffd88a 0 50%, var(--orange) 50%); color: #201604; border-color: var(--ink); }
.pager { display: flex; gap: 8px; align-items: center; justify-content: center; margin-top: 8px; min-height: 25px; }
table.score tbody tr.fill-row:hover td { background: none; }
table.score tbody tr.fill-row td { color: transparent; }
/* 결과 화면에서는 좌하단 FAB 스택 숨김 — 모바일에서 점수표와 겹침 (종료 버튼이 모두 리로드라 복구 불필요) */
body.result-open #fab-col, body.result-open #btn-main-fab, body.result-open #chat-wrap, body.result-open #build-ver { display: none !important; }
.pager .pager-btn { padding: 3px 12px; font-size: 11px; }
.pager .pager-btn:disabled { opacity: .35; pointer-events: none; }
.pager .pg-info { font-size: 11px; color: #9d93c4; min-width: 92px; text-align: center; }
/* 설정 버튼 — 좌하단 채팅 버튼 아래로 이동 (타이틀에서 채팅 FAB은 위로 올라감) */
/* 좌하단 공통 버튼 스택 — 타이틀/게임 공통. 아래→위: 설정, 랭킹, 채팅, (게임 중) 메인 */
#fab-col { position: fixed; left: 10px; bottom: 10px; z-index: 62; display: flex; flex-direction: column; gap: 8px; }
/* v0.2.27 — FAB 재디자인: 파스텔 플랫 버튼 폐기, 게임 HUD와 같은 다크 단말 패널 + 기능색 네온 테두리·LED */
#fab-col .cartoon-btn, #btn-main-fab, #chat-fab {
  --ac: #39e06a; /* 기능색 — 버튼별로 아래서 지정 */
  background: linear-gradient(180deg, rgba(12, 18, 10, .92), rgba(5, 9, 5, .94));
  border: 2px solid var(--ac); border-radius: 0; color: #d8ffe2;
  box-shadow: 0 0 10px color-mix(in srgb, var(--ac) 35%, transparent), inset 0 0 0 1px rgba(0, 0, 0, .6), inset 0 0 18px rgba(0, 0, 0, .45);
  text-shadow: 0 0 6px color-mix(in srgb, var(--ac) 60%, transparent), 1px 1px 0 #000;
  position: relative; overflow: hidden;
}
/* 좌측 LED 노치 — 단말 인디케이터 */
#fab-col .cartoon-btn::after, #btn-main-fab::after, #chat-fab::after {
  content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 4px;
  background: var(--ac); box-shadow: 0 0 8px var(--ac);
}
#fab-col .cartoon-btn:hover, #btn-main-fab:hover, #chat-fab:hover {
  filter: none; background: linear-gradient(180deg, rgba(18, 28, 14, .95), rgba(8, 13, 7, .95));
  box-shadow: 0 0 16px color-mix(in srgb, var(--ac) 55%, transparent), inset 0 0 0 1px rgba(0, 0, 0, .6);
}
#fab-col .cartoon-btn:active, #btn-main-fab:active, #chat-fab:active { transform: translate(1px, 1px); box-shadow: 0 0 6px color-mix(in srgb, var(--ac) 30%, transparent); }
#btn-main-fab { --ac: #ff5040; }   /* 메인 — 적색 */
#chat-fab { --ac: #39e06a; }       /* 채팅 — 녹색 */
#fab-col #btn-rank { --ac: #ffb03a; }  /* 랭킹 — 금색 (fab-col 기본색보다 특이도 높임) */
#fab-col #btn-settings2 { --ac: #3f9fe0; } /* 설정 — 청색 */
#fab-col .cartoon-btn, #btn-main-fab, #chat-fab { min-width: 110px; height: 40px; font-size: 14px; padding: 7px 12px; }
#fab-col .cartoon-btn, #chat-fab { display: inline-flex; align-items: center; justify-content: center; gap: 7px; }
#btn-main-fab::before, #btn-rank::before, #btn-settings2::before, #chat-fab::before { font-size: 16px; line-height: 1; }
#btn-main-fab::before { content: '🏠'; }
#btn-rank::before { content: '🏆'; }
#btn-settings2::before { content: '⚙️'; }
#chat-fab::before { content: '💬'; }
#btn-main-fab { display: none; position: fixed; left: 10px; bottom: 154px; z-index: 62; }
body.in-game #btn-main-fab { display: inline-flex; align-items: center; justify-content: center; gap: 7px; }
#chat-wrap { bottom: 106px; }

/* ---------- 레벨업 ---------- */
#upgrade-overlay { background: rgba(13, 10, 24, .82); z-index: 45; }
#upgrade-inner { text-align: center; padding: 20px 16px; max-width: min(1460px, 94vw); width: 100%; }
#upgrade-title {
  font-family: 'Galmuri11', 'Press Start 2P', sans-serif; font-size: clamp(28px, 4.6vw, 50px);
  color: var(--yellow); text-shadow: 3px 3px 0 #000; letter-spacing: 3px;
  margin-bottom: 4px; animation: alertIn .4s cubic-bezier(.2, 1.6, .4, 1);
}
#upgrade-sub { color: var(--dim); font-family: 'Galmuri14', 'Galmuri11', sans-serif; font-size: 14px; margin-bottom: 22px; letter-spacing: 1px; }
#upgrade-cards { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 22px; }
#upgrade-cards .up-card:nth-child(4):last-child { grid-column: 2; } /* 카드 4장(무장 교체)일 때 마지막 카드 가운데 정렬 */
.up-card {
  --th: #ffb03a; --th2: #8a4a0a;
  min-width: 0; background: #0d130d;
  border: 3px solid #2c3a2e; border-radius: 0; overflow: hidden;
  box-shadow: 5px 5px 0 rgba(0, 0, 0, .5), inset 0 0 0 2px #1a2013; cursor: pointer; color: var(--cream);
  animation: cardIn .5s cubic-bezier(.2, 1.5, .4, 1) backwards;
  transition: transform .12s; position: relative;
}
/* 카드 종류별 구분 (v0.2.18 강화) — 테두리·본체 틴트·밴드·아이콘 프레임·선택 버튼까지
   타입 컬러로 통일해 한눈에 구별. 무장 강화는 무기 테마색 대신 타입 컬러 우선(스캔성 우선) */
.up-card.k-stat { border-color: #2a6a9a; background: #0c141d; }
.up-card.k-stat .up-band { background: #0e2438; color: #54b4f0; }
.up-card.k-stat .up-icon img { border-color: #2a6a9a; background: #0e1a24; }
.up-card.k-stat .up-btn { border-color: #54b4f0; color: #7cc8f8; background: #0e2438; }
.up-card.k-stat:hover { border-color: #54b4f0; }
.up-card.k-w { border-color: #8a5a1a; background: #171206; }
.up-card.k-w .up-band { background: #2e2008; color: #ffb03a; }
.up-card.k-w .up-icon img { border-color: #8a5a1a; background: #1e1808; }
.up-card.k-w .up-btn { border-color: #ffb03a; color: #ffc85e; background: #2e2008; }
.up-card.k-w:hover { border-color: #ffb03a; }
.up-card.k-new { border-color: #1d7a44; background: #0a170e; }
.up-card.k-new .up-band { background: #10301c; color: #57ff9e; }
.up-card.k-new .up-icon img { border-color: #1d7a44; background: #0e2414; }
.up-card.k-new .up-btn { border-color: #3ce86e; color: #6fffa0; background: #10301c; }
.up-card.k-new:hover { border-color: #3ce86e; }
.up-card.k-score { border-color: #8a7a18; background: #171505; }
.up-card.k-score .up-band { background: #2e2608; color: #ffe23c; }
.up-card.k-score .up-icon img { border-color: #8a7a18; background: #201c08; }
.up-card.k-score .up-btn { border-color: #ffe23c; color: #ffec7a; background: #2e2608; }
.up-card.k-score:hover { border-color: #ffe23c; }
.up-tag {
  position: absolute; top: 34px; right: 0; z-index: 2;
  padding: 3px 9px; font-family: 'Galmuri11', 'Press Start 2P', 'Galmuri11', sans-serif; font-size: 10px; letter-spacing: 1px;
  color: #060805; border: 2px solid var(--ink); border-right: none;
  box-shadow: 3px 3px 0 rgba(0, 0, 0, .3);
}
.tag-new { background: #3ce86e; animation: tagBlink 1s steps(2) infinite; }
.tag-w { background: #ffb03a; }
.tag-stat { background: #54b4f0; }
.tag-score { background: #ffe23c; }
@keyframes tagBlink { 50% { filter: brightness(1.35); } }
.up-card:hover { transform: translateY(-6px); }
@keyframes cardIn { from { transform: translateY(60px) scale(.6); opacity: 0; } }
.up-band { background: #26200f; color: var(--th); font-family: 'Galmuri11', sans-serif; font-size: 11px; letter-spacing: 3px; padding: 8px 9px; border-bottom: 2px solid var(--ink); text-shadow: none; }
.up-icon { padding: 14px 0 6px; }
.up-icon img { width: 128px; height: 128px; border: 2px solid var(--line); background: #141812; image-rendering: pixelated; }
.up-name { font-size: 22px; font-family: 'Galmuri11', sans-serif; padding: 0 10px; color: #eafbef; letter-spacing: 1px; }
.up-sub { font-size: 11px; color: var(--dim); margin: 3px 0 7px; }
.up-sub .up-grow { display: inline-block; margin-top: 3px; font-size: 10px; color: var(--green); opacity: .9; }
.up-stat { font-family: 'Galmuri14', 'Galmuri11', sans-serif; font-size: 14px; color: var(--orange); }
.up-desc { font-size: 11px; line-height: 1.55; padding: 0 18px 14px; min-height: 48px; color: #9ab8a4; }
.up-btn { margin: 0 18px 16px; padding: 10px; background: #173324; border: 2px solid var(--green); font-size: 16px; letter-spacing: 3px; color: var(--green); box-shadow: 3px 3px 0 rgba(0, 0, 0, .5); font-family: 'Galmuri11', sans-serif; }
.up-card:active .up-btn { box-shadow: 1px 1px 0 rgba(0, 0, 0, .5); }
.up-card.chosen { animation: chosenPop .55s forwards; z-index: 3; }
@keyframes chosenPop {
  30% { transform: scale(1.12) rotate(1.5deg); box-shadow: 0 0 0 6px var(--yellow), 12px 12px 0 rgba(0, 0, 0, .5); }
  100% { transform: scale(1.18); opacity: 0; }
}
.up-card.rejected { animation: rejectOut .5s forwards; }
@keyframes rejectOut { to { transform: translateY(70px) rotate(6deg) scale(.7); opacity: 0; } }
.up-stamp {
  position: fixed; left: 50%; top: 50%; transform: translate(-50%, -50%) rotate(-9deg);
  font-family: 'Galmuri11', sans-serif; font-size: clamp(40px, 8vw, 84px); letter-spacing: 4px;
  color: var(--yellow); -webkit-text-stroke: 3px var(--ink);
  text-shadow: 6px 6px 0 #000; animation: stampIn .45s cubic-bezier(.2, 2, .4, 1); pointer-events: none; z-index: 5;
}
@keyframes stampIn { from { transform: translate(-50%, -50%) rotate(-9deg) scale(3); opacity: 0; } }
.burst-star { position: fixed; width: 14px; height: 14px; margin: -7px; pointer-events: none; z-index: 60; background: var(--c, #ffe23c); clip-path: polygon(50% 0, 63% 37%, 100% 50%, 63% 63%, 50% 100%, 37% 63%, 0 50%, 37% 37%); animation: starFly .8s ease-out forwards; }
@keyframes starFly { to { transform: translate(var(--dx), var(--dy)) rotate(220deg) scale(.2); opacity: 0; } }

/* ---------- 설정 ---------- */
#settings-overlay { background: rgba(13, 10, 24, .8); z-index: 50; }
#main-exit-overlay { background: rgba(13, 10, 24, .82); z-index: 51; }
.sheet { width: min(460px, 94vw); padding: 20px 22px; }
.sheet h2 { font-family: 'Galmuri11', sans-serif; color: var(--yellow); font-size: 21px; margin-bottom: 14px; letter-spacing: 2px; text-shadow: 2px 2px 0 #000; border-bottom: 2px solid var(--line2); padding-bottom: 9px; }
.set-row { margin-bottom: 14px; }
.set-row label { display: block; font-size: 11px; color: var(--dim); margin-bottom: 5px; letter-spacing: 1px; }
input[type=range] { width: 100%; accent-color: var(--orange); height: 26px; }
.bgm-tracks { display: flex; gap: 6px; flex-wrap: wrap; }
.bgm-tracks .cartoon-btn { font-family: 'Galmuri11', sans-serif; font-size: 11px; padding: 5px 10px; }
.yt-row { display: flex; gap: 6px; }
#yt-url { flex: 1; font-family: inherit; font-size: 11px; padding: 8px 10px; border: 2px solid var(--line); background: #0a0e06; color: var(--green); min-width: 0; }
.yt-btns { display: flex; gap: 6px; margin-top: 7px; }
.yt-btns .cartoon-btn { font-family: 'Galmuri11', sans-serif; font-size: 11px; padding: 6px 12px; }
#bgm-status { font-size: 11px; color: var(--green); margin-top: 6px; min-height: 15px; }
.sheet .foot { display: flex; gap: 8px; justify-content: flex-end; margin-top: 8px; }
/* 유튜브 플레이어 — 완전 숨김 (소리만 재생) */
#yt-box { position: fixed; right: 0; bottom: 0; width: 200px; height: 120px; z-index: -1; opacity: 0; pointer-events: none; overflow: hidden; }

/* ---------- 게임 시작 안내 토스트 ---------- */
#guide-toast { position: fixed; top: 16%; left: 50%; transform: translateX(-50%); z-index: 55; background: rgba(10, 12, 5, .9); border: 2px solid var(--line); padding: 12px 22px; font-family: 'Galmuri14', 'Galmuri11', sans-serif; font-size: 14px; color: #fff; text-align: center; line-height: 1.5; box-shadow: 5px 5px 0 rgba(0, 0, 0, .4); transition: opacity .8s; pointer-events: none; letter-spacing: 1px; }
#guide-toast.fade { opacity: 0; }

/* ---------- 보급 슬롯 — NERV MAGI 보급 판정 터미널 (슬롯 작동 중 게임은 pauseGame으로 정지) ---------- */
#slot-overlay { z-index: 58; overflow: hidden; background: rgba(10, 12, 5, .93); }
#slot-sheet { position: relative; text-align: center; width: min(1240px, 96vw); padding: 0; border: 6px solid #b3541e; border-radius: 0; box-shadow: 0 0 0 4px var(--ink), 0 14px 0 rgba(0, 0, 0, .45); overflow: hidden;
  /* 군용 터미널 패널 — 4코너 볼트 + 상단 하드 하이라이트 밴드 */
  background:
    linear-gradient(#6a5a28, #6a5a28) 16px 16px / 8px 8px,
    linear-gradient(#6a5a28, #6a5a28) calc(100% - 16px) 16px / 8px 8px,
    linear-gradient(#4a4020, #4a4020) 16px calc(100% - 16px) / 8px 8px,
    linear-gradient(#4a4020, #4a4020) calc(100% - 16px) calc(100% - 16px) / 8px 8px,
    linear-gradient(180deg, #3a4020 0 10px, #22261a 10px 70%, #14160d 70%);
  background-repeat: no-repeat; }
/* 헤더 — 위험표시 테이프 2줄 + 판정 타이틀 */
#slot-marquee { position: relative; padding: 0 30px 18px; background: #10120a; border-bottom: 5px solid #b3541e; }
#slot-marquee .hz { display: block; height: 12px;
  background: repeating-linear-gradient(45deg, #ff9435 0 14px, #14160d 14px 28px);
  animation: hzroll .7s steps(2) infinite; }
#slot-marquee .hz:last-child { animation-delay: .35s; }
@keyframes hzroll { to { background-position-x: 28px; } }
#slot-sheet h2 { font-family: 'Press Start 2P', 'Galmuri11', 'Jua', sans-serif; font-size: 40px; letter-spacing: 4px; margin: 16px 0 8px; color: #ffb03a; text-shadow: 4px 4px 0 var(--ink); }
#slot-sheet h2 small { display: block; margin-top: 8px; font-size: 11px; letter-spacing: 5px; color: var(--green); }
/* 머신 본체 — 릴 창 + 레버 */
#slot-body { display: flex; align-items: stretch; padding: 0 30px; }
/* 하단 LED 계기판 — 표결 패널 아래 가로 3셀 스트립 */
#slot-meters { display: flex; gap: 10px; margin: 4px 0 0; }
#slot-meters span { flex: 1; display: flex; justify-content: flex-start; align-items: center; gap: 9px; padding: 4px 10px;
  font: 16px/1.2 'Press Start 2P', 'Galmuri11', monospace; letter-spacing: 1px; color: #4a9a62; white-space: nowrap; /* v0.2.24 — 라틴 라벨은 PS2P 8px 네이티브(두꺼운 비트맵)로 확실한 픽셀감, 한글은 갈무리 폴백 */
  background: #050704; border: 2px solid #2a3a1e; border-radius: 0; box-shadow: inset 0 0 0 2px #020402; }
#slot-meters span::before { content: ''; flex: 0 0 8px; width: 8px; height: 8px; background: #39e06a;
  animation: ledblink 1.8s steps(1) infinite; }
#slot-meters span:nth-child(2)::before { background: #ffb03a; animation-delay: .6s; }
#slot-meters span:nth-child(3)::before { background: #ff5040; animation-delay: 1.2s; }
@keyframes ledblink { 0%, 55% { opacity: 1; } 56%, 100% { opacity: .2; } }
#slot-meters b { margin-left: auto; color: var(--green); font-family: 'Press Start 2P', 'Galmuri11', monospace; font-size: 16px; font-weight: 400; letter-spacing: 1px; white-space: nowrap; flex-shrink: 0; }
/* 통풍구 — 머신 좌우 가장자리 픽셀 도트 매트릭스 */
#slot-body::before, #slot-body::after { content: ''; flex: 0 0 26px; align-self: center; height: 70%;
  background: repeating-linear-gradient(0deg, #0a0c06 0 6px, transparent 6px 14px) 4px 0 / 9px 14px,
              repeating-linear-gradient(0deg, #0a0c06 0 6px, transparent 6px 14px) 15px 7px / 9px 14px;
  background-repeat: repeat-y; opacity: .95; }
/* 보급 슈트 — 하단 위험표시 스트라이프 + 레이블 */
#slot-tray { position: relative; height: 38px; margin: 0 30px 4px; border-radius: 0;
  background: repeating-linear-gradient(45deg, #b3541e 0 14px, #14160d 14px 28px) left bottom / 100% 13px no-repeat, #0c0e07;
  border: 3px solid var(--ink); box-shadow: inset 0 6px 0 rgba(0,0,0,.55); }
#slot-tray::after { content: 'SUPPLY CHUTE'; position: absolute; left: 50%; top: 7px; transform: translateX(-50%);
  font: 9px 'Press Start 2P', monospace; letter-spacing: 2px; color: #6a5a30; }
/* 잭팟 배경 — 당첨 시 전체 오버레이가 황금빛으로 */
#slot-overlay.win-bg { background: rgba(56, 40, 8, .94); }
/* JACKPOT 배너 — 팝업 후 반짝임 (하드 오프셋 그림자만, 글로우 없음) */
#slot-jackpot { position: absolute; left: 50%; top: 42%; transform: translate(-50%, -50%) scale(0); z-index: 6; pointer-events: none;
                font-family: 'Press Start 2P', 'Galmuri11', 'Jua', sans-serif; font-size: clamp(24px, 4.6vw, 54px); letter-spacing: 3px; color: #ffe23c;
                white-space: nowrap; text-shadow: 5px 5px 0 #151024, 10px 10px 0 #b3541e; }
#slot-jackpot.show { animation: jpop .6s cubic-bezier(.2, 1.6, .4, 1) forwards, jflash .45s .6s ease-in-out infinite alternate; }
@keyframes jpop { 0% { transform: translate(-50%, -50%) scale(.2) rotate(-16deg); } 62% { transform: translate(-50%, -50%) scale(1.3) rotate(5deg); } 100% { transform: translate(-50%, -50%) scale(1) rotate(-2deg); } }
@keyframes jflash { from { filter: brightness(1); } to { filter: brightness(1.65); } }
/* 컨페티 — 승리 시 화면 위로부터 쏟아지는 색종이 */
.confetti { position: absolute; top: -16px; width: 9px; height: 13px; z-index: 7; pointer-events: none; animation: confall var(--t, 1.8s) cubic-bezier(.3, .4, .7, 1) forwards; image-rendering: pixelated; }
@keyframes confall { 0% { transform: translateY(0) rotate(0) scale(1); opacity: 1; } 82% { opacity: 1; } 100% { transform: translateY(106vh) translateX(var(--dx, 0px)) rotate(640deg) scale(.9); opacity: 0; } }
/* 전체 화면 플래시 — 잭팟 순간 화면이 번쩍 */
#slot-flash { position: absolute; inset: 0; background: #fff8dc; opacity: 0; pointer-events: none; z-index: 8; }
#slot-flash.go { animation: sflash .55s ease-out; }
@keyframes sflash { 0% { opacity: .9; } 100% { opacity: 0; } }
/* 잭팟 상태문구 — 더 크고 황금색 */
#slot-status.jackpot-status { font-size: 32px; color: var(--yellow); }
/* 스핀 중 — 시트 안쪽 둘레를 도는 위험표시 스트라이프 프레임 (steps로 뚝뚝 도는 픽셀 점등) */
#slot-sheet.rolling::before { content: ''; position: absolute; inset: 4px; z-index: 9; pointer-events: none;
  border: 9px solid #ff9435;
  border-image: repeating-linear-gradient(45deg, #ff9435 0 14px, #14160d 14px 28px) 9 / 9px / 0 repeat;
  animation: stripeschase .55s steps(3) infinite; }
@keyframes stripeschase {
  0%   { border-image-source: repeating-linear-gradient(45deg, #ff9435 0 14px, #14160d 14px 28px); }
  100% { border-image-source: repeating-linear-gradient(45deg, #14160d 0 14px, #ff9435 14px 28px); } }
/* 스핀 중 떠다니는 반짝이 파티클 */
.slot-sparkle { position: absolute; width: 7px; height: 7px; background: #fff8dc;
                pointer-events: none; z-index: 4;
                animation: stw .6s steps(2) infinite alternate; }
@keyframes stw { from { opacity: .1; transform: scale(.4); } to { opacity: 1; transform: scale(1.35); } }
/* 스핀 중 화면 전체를 흩날리는 픽셀 조각 — 픽셀아트풍 사각 파티클 */
.slot-px { position: absolute; top: -16px; width: 10px; height: 10px; z-index: 4; pointer-events: none;
  animation: pxfall var(--t, 2.4s) linear forwards; }
.slot-px.px-oct { clip-path: polygon(30% 0, 70% 0, 100% 30%, 100% 70%, 70% 100%, 30% 100%, 0 70%, 0 30%); }
@keyframes pxfall {
  0%   { transform: translateY(0) translateX(0) rotate(0); opacity: 0; }
  8%   { opacity: .95; }
  50%  { transform: translateY(56vh) translateX(var(--dx, 0px)) rotate(180deg); }
  100% { transform: translateY(112vh) translateX(0) rotate(360deg); opacity: .4; }
}
/* 잭팟 시 화면 전체에 쏟아지는 픽셀 코인/심볼 아이콘 */
.slot-coin { position: absolute; top: -52px; width: var(--s, 44px); height: var(--s, 44px); z-index: 7;
  pointer-events: none; image-rendering: pixelated;
  animation: coinfall var(--t, 2.2s) cubic-bezier(.25, .5, .6, 1) forwards; }
@keyframes coinfall {
  0%   { transform: translateY(0) translateX(0) rotate(0) scale(1); opacity: 0; }
  7%   { opacity: 1; }
  60%  { transform: translateY(62vh) translateX(var(--dx, 0px)) rotate(300deg); }
  100% { transform: translateY(114vh) translateX(0) rotate(720deg); opacity: .5; }
}
/* 잭팟 버스트 — 머신에서 방사형으로 터지는 픽셀 별 */
.slot-burst { position: absolute; left: 50%; top: 42%; width: 26px; height: 26px; z-index: 7; pointer-events: none;
  clip-path: polygon(30% 0, 70% 0, 100% 30%, 100% 70%, 70% 100%, 30% 100%, 0 70%, 0 30%);
  animation: burstfly var(--t, 1.3s) cubic-bezier(.1, .7, .3, 1) forwards; }
@keyframes burstfly {
  0%   { transform: translate(-50%, -50%) scale(.3); opacity: 1; }
  100% { transform: translate(calc(-50% + var(--bx, 0px)), calc(-50% + var(--by, 0px))) scale(1.5) rotate(160deg); opacity: 0; }
}
/* 잭팟 시 머신 흔들림 */
#slot-sheet.win-shake { animation: sheetshake .5s ease-in-out; }
@keyframes sheetshake {
  0%, 100% { transform: translate(0, 0) rotate(0); }
  20% { transform: translate(-9px, 4px) rotate(-.7deg); }
  40% { transform: translate(8px, -5px) rotate(.6deg); }
  60% { transform: translate(-6px, -3px) rotate(-.4deg); }
  80% { transform: translate(5px, 3px) rotate(.3deg); }
}
#slot-main { flex: 1; display: flex; flex-direction: column; gap: 18px; margin: 26px 0; min-width: 0; }
/* 상단 — 보급 카드 플로우 (안건 컨베이어) */
#slot-flow { position: relative; height: 148px; background: #0a0c06; border: 4px solid var(--ink); border-radius: 0;
  box-shadow: inset 0 0 0 5px #232812, inset 0 10px 0 rgba(0, 0, 0, .45); overflow: hidden; }
/* 좌우 끝 페이드 — 카드가 터널 속으로 들어가는 느낌 */
#slot-flow::before { content: ''; position: absolute; inset: 0; z-index: 2; pointer-events: none;
  background: linear-gradient(90deg, #0a0c06 0%, transparent 14%, transparent 86%, #0a0c06 100%); }
/* CRT 스캔라인 — 판정 창에 레트로 가로줄 */
#slot-flow::after { content: ''; position: absolute; inset: 0; z-index: 2; pointer-events: none;
  background: repeating-linear-gradient(0deg, rgba(0, 0, 0, .22) 0 3px, transparent 3px 6px); }
#flow-track { position: absolute; top: 50%; left: 50%; height: 118px; margin-top: -59px; display: flex; gap: 14px;
  will-change: transform; }
#flow-track.run { transition: transform 2.6s cubic-bezier(.12, .78, .18, 1); }
.flow-card { flex: 0 0 96px; height: 118px; display: flex; align-items: center; justify-content: center;
  background: #141812; border: 3px solid #3a4224; image-rendering: pixelated; }
.flow-card img { width: 82%; height: 82%; object-fit: contain; image-rendering: pixelated; pointer-events: none; }
.flow-card.sel { border-color: #ffe23c; background: #2a2410; animation: selblink .4s steps(2) 3 alternate; }
@keyframes selblink { from { filter: brightness(1); } to { filter: brightness(1.75); } }
/* 선택 지시 바늘 — 중앙 상하 삼각 마커 + 점선 */
.flow-needle { position: absolute; left: 50%; top: 0; bottom: 0; width: 0; z-index: 3; transform: translateX(-50%); pointer-events: none;
  border-left: 2px dashed rgba(255, 226, 60, .75); }
.flow-needle::before, .flow-needle::after { content: ''; position: absolute; left: 50%; transform: translateX(-50%);
  width: 0; height: 0; border-left: 10px solid transparent; border-right: 10px solid transparent; }
.flow-needle::before { top: 0; border-top: 12px solid #ffe23c; }
.flow-needle::after { bottom: 0; border-bottom: 12px solid #ffe23c; }
/* 확정 안건 표시 — 선택 카드 아이콘 + 명칭 */
#slot-agenda { display: flex; align-items: center; gap: 16px; margin: 10px 0; padding: 8px 14px;
  background: #0a0c06; border: 4px solid var(--ink); box-shadow: inset 0 0 0 4px #232812; min-height: 68px;
  position: relative; overflow: hidden; }
#slot-agenda::after { content: ''; position: absolute; inset: 0; pointer-events: none;
  background: repeating-linear-gradient(0deg, rgba(0, 0, 0, .18) 0 3px, transparent 3px 6px); }
.agenda-tag { font: 9px 'Press Start 2P', monospace; letter-spacing: 2px; color: #ffb03a; flex: 0 0 auto; }
#agenda-icon { width: 56px; height: 56px; image-rendering: pixelated; opacity: 0; flex: 0 0 auto; }
#agenda-name { font: 20px 'Galmuri11', 'Press Start 2P', monospace; letter-spacing: 1px; color: #6b7a50;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#slot-agenda.set { border-color: #e8871e; animation: agendapop .3s steps(3); }
#slot-agenda.set #agenda-icon { opacity: 1; }
#slot-agenda.set #agenda-name { color: #ffe23c; }
@keyframes agendapop { 0% { transform: scale(1.04); filter: brightness(1.8); } 100% { transform: scale(1); filter: none; } }
/* 하단 — MAGI 3기 표결 패널 */
#slot-vote { display: flex; gap: 40px; justify-content: center; padding: 18px 20px; background: #0a0c06;
  border: 4px solid var(--ink); box-shadow: inset 0 0 0 5px #232812; position: relative; }
#slot-vote::after { content: ''; position: absolute; inset: 0; pointer-events: none;
  background: repeating-linear-gradient(0deg, rgba(0, 0, 0, .18) 0 3px, transparent 3px 6px); }
#slot-overlay.rolling #slot-vote { animation: reelframe .5s steps(2) infinite alternate; }
@keyframes reelframe { from { border-color: var(--ink); } to { border-color: #e8871e; } }
.vres { font: 12px 'Galmuri11', monospace; letter-spacing: 1px; color: #6b7a50; min-height: 16px; }
.vres.yes { color: #57ff9e; }
.vres.no { color: #ff5040; }
/* MAGI 판정기 — 기체명 태그 + AT필드 육각 창 */
.magi { display: flex; flex-direction: column; align-items: center; gap: 10px; }
.magi-tag { font: 10px 'Galmuri9', 'Press Start 2P', monospace; letter-spacing: 2px; color: #ffb03a; }
.magi-hex { padding: 5px; background: #3a2e10; clip-path: polygon(25% 0, 75% 0, 100% 50%, 75% 100%, 25% 100%, 0 50%); transition: background .25s; }
.vote { width: min(150px, 19vw); height: min(150px, 19vw); display: flex; align-items: center; justify-content: center;
  font-family: 'Press Start 2P', 'Galmuri11', sans-serif; font-size: min(30px, 4vw); color: #6b7a50; letter-spacing: 2px;
  background: #0e120a; clip-path: polygon(25% 0, 75% 0, 100% 50%, 75% 100%, 25% 100%, 0 50%); transition: filter .2s; }
.vote.voting { animation: reelspin .09s steps(2) infinite; filter: brightness(1.55) contrast(1.25); }
@keyframes reelspin { 0% { transform: translateY(-14px) scaleY(.92); } 50% { transform: translateY(0); } 100% { transform: translateY(14px) scaleY(.92); } }
.vote.yes { color: #57ff9e; background: #10301c; }
.vote.no { color: #ff5040; background: #381010; }
.magi-hex:has(.vote.voting) { background: #e8871e; }
.magi-hex:has(.vote.yes) { background: #57ff9e; }
.magi-hex:has(.vote.no) { background: #ff5040; }
/* 착지 — 판정 확정 순간 쾅 하고 멈추는 타격감 */
.vote.stop { animation: reelslam .26s steps(3); }
@keyframes reelslam { 0% { transform: scale(1.22); filter: brightness(2.4); } 100% { transform: scale(1); filter: none; } }
#slot-sheet.slam { animation: sheetslam .18s steps(2); }
@keyframes sheetslam { 0% { transform: translateY(0); } 45% { transform: translateY(6px); } 100% { transform: translateY(0); } }
/* 리치 — 1:1 분열 후 CASPAR 최종 심의의 긴장 연출 */
#slot-overlay.reach .magi-hex:has(.vote.voting) { background: #ff5040; animation: reachpulse .24s steps(2) infinite alternate; }
@keyframes reachpulse { from { background: #ff5040; } to { background: #ffb03a; } }
#slot-overlay.reach .vote:not(.voting) { filter: brightness(.5); }
#slot-overlay.reach #slot-status { color: var(--yellow); }
/* 부결 — 기각 시 붉은 분위기 */
#slot-overlay.fail-bg { background: rgba(40, 10, 8, .94); }
#slot-jackpot.fail { color: #ff5040; }
#slot-status { font-family: 'Galmuri11', monospace; font-size: 26px; color: var(--green); min-height: 56px; line-height: 1.4; display: flex; align-items: center; justify-content: center; padding: 12px 16px 10px; word-break: keep-all;
  background: #0a0c06; border-top: 5px solid var(--ink); }
#slot-status::after { content: '▮'; margin-left: 8px; font-size: .8em; animation: cblink .9s steps(1) infinite; }
@keyframes cblink { 50% { opacity: 0; } }
#set-spd-v { min-width: 56px; text-align: right; color: var(--yellow); font-size: 16px; }
/* 잭팟 광선 — 화면 가득 회전하는 황금 광선 */
#slot-rays { position: absolute; inset: -60%; display: none; pointer-events: none; z-index: 5;
  background: repeating-conic-gradient(from 0deg, rgba(255, 148, 53, .22) 0 12deg, transparent 12deg 24deg);
  animation: rayrot 7s steps(30) infinite; }
#slot-overlay.win-bg #slot-rays { display: block; }
@keyframes rayrot { to { transform: rotate(1turn); } }
#btn-up-pass { margin-top: 18px; font-size: 18px; padding: 15px 30px; width: 100%; }
#stat-bonus { margin-top: 7px; padding-top: 6px; border-top: 1px dashed rgba(255, 255, 255, .18); font-size: 11px; line-height: 1.6; color: var(--yellow); }
#boss-next { font-family: 'Galmuri11', monospace; font-size: 11px; margin-top: 3px; }
#boss-next.wave-wait { color: var(--orange); }
#boss-next.wave-fight { color: #ff5e5e; animation: wavepulse 1s infinite; }
#crate-next { font-family: 'Galmuri11', monospace; font-size: 11px; margin-top: 1px; color: #ffb35c; } /* 미사용 — 보급 타이머는 미니맵 캔버스 렌더링으로 이전 */
@keyframes wavepulse { 50% { opacity: .5; } }
.map-sub { color: #8fb8c8; font-size: 10px; }

/* ---------- 결과 ---------- */
#result-overlay { background: rgba(13, 10, 24, .86); z-index: 46; }
.sheet.result { width: min(620px, 95vw); }
#result-title { text-align: center; }
#result-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 14px; }
.res-cell { background: #0d130d; border: 2px solid var(--line); text-align: center; padding: 8px 4px; }
.res-cell b { display: block; font-size: 16px; color: var(--yellow); font-family: 'Press Start 2P', 'Galmuri11', monospace; font-weight: 400; }
.res-cell span { font-size: 11px; color: var(--dim); letter-spacing: 1px; }
.name-row { display: flex; gap: 7px; margin-bottom: 10px; }
#score-name { flex: 1; font-family: 'Galmuri14', 'Galmuri11', sans-serif; font-size: 14px; padding: 8px 12px; border: 2px solid var(--line); background: #0a0e06; color: var(--green); min-width: 0; }
#score-status { font-size: 11px; color: var(--green); min-height: 17px; margin-bottom: 6px; }

/* ---------- 패치 게시판 — NERV 단말기 스타일, 카운터 위 ---------- */
#patch-board { width: 100%; margin: 26px auto 0; text-align: left;
  background: #0a0c06; border: 3px solid var(--ink); box-shadow: inset 0 0 0 3px #232812;
  position: relative; }
#patch-board::before { content: ''; display: block; height: 8px;
  background: repeating-linear-gradient(45deg, #e8871e 0 10px, #151024 10px 20px); }
.pb-head { display: flex; align-items: center; justify-content: space-between; padding: 8px 14px 4px;
  font: 10px 'Galmuri9', 'Press Start 2P', monospace; letter-spacing: 2px; color: #ffb03a; }
.pb-sub { font-size: 7px; color: #6b7a50; letter-spacing: 1px; }
.pb-list { max-height: 170px; overflow-y: auto; padding: 4px 14px 12px; }
.pb-list::-webkit-scrollbar { width: 6px; }
.pb-list::-webkit-scrollbar-thumb { background: #3a4224; }
.pb-row { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px; padding: 6px 0;
  border-bottom: 1px dashed #232812; font-family: 'Galmuri11', monospace; }
.pb-row:last-child { border-bottom: none; }
.pb-ver { flex: 0 0 auto; min-width: 62px; color: #57ff9e; font-family: 'Galmuri9', 'Press Start 2P', monospace;
  font-size: 9px; letter-spacing: 1px; }
.pb-date { color: #4a5a3a; font-size: 11px; }
.pb-items { flex: 1 1 auto; display: flex; flex-direction: column; gap: 2px; }
.pb-item { font-size: 11px; color: #9ab87a; line-height: 1.5; word-break: keep-all; }
.pb-row:first-child .pb-ver { color: #ffe23c; }
.pb-row:first-child .pb-item { color: #cfe8a8; }

/* ---------- 방문자 카운터 — 페이지 최하단 ---------- */
#visit-row { margin: 30px 0 4px; text-align: center; }
#copyright { margin-top: 26px; text-align: center; font-size: 11px; line-height: 1.7; color: #6b6488; }

/* ---------- 타이틀 좌우 장식 패널 — 와이드 화면에서만 표시 ---------- */
.tdeco { position: fixed; top: 0; bottom: 0; width: 240px; pointer-events: none; display: none; }
.tdeco-l { left: 0; } .tdeco-r { right: 0; }
.tdeco .td-stripes { position: absolute; top: 0; bottom: 0; width: 20px;
  background: repeating-linear-gradient(-45deg, #ff9435 0 12px, #151024 12px 24px); opacity: .7; }
.tdeco-l .td-stripes { left: 0; } .tdeco-r .td-stripes { right: 0; }
.tdeco .td-vtext { position: absolute; top: 34px; writing-mode: vertical-rl; font-size: 14px;
  letter-spacing: 7px; color: #8fb4d0; font-family: 'Galmuri14', 'Press Start 2P', 'Galmuri11', monospace; opacity: .85; }
.tdeco-l .td-vtext { left: 36px; } .tdeco-r .td-vtext { right: 36px; }
.tdeco .td-term { position: absolute; top: 60px; font-family: 'Galmuri11', monospace; font-size: 11px;
  line-height: 2.1; color: #6fd8a8; letter-spacing: 1px; opacity: .9; }
.tdeco-l .td-term { left: 60px; } .tdeco-r .td-term { right: 60px; text-align: right; }
.tdeco .td-sprite { position: absolute; bottom: 40px; width: 190px; image-rendering: pixelated;
  filter: drop-shadow(0 0 22px rgba(0, 0, 0, .7)); }
.tdeco-l .td-sprite { left: 28px; } .tdeco-r .td-sprite { right: 28px; }
/* 4K 좌우 여백 보강 — 두 번째 스프라이트 + HUD 패널 + 팔각 코어 + 도트 그리드 */
.tdeco .td-sprite2 { position: absolute; bottom: 320px; width: 120px; image-rendering: pixelated; opacity: .85;
  filter: drop-shadow(0 0 10px rgba(127, 240, 255, .3)); }
.tdeco-l .td-sprite2 { left: 96px; } .tdeco-r .td-sprite2 { right: 96px; }
.tdeco .td-panel { position: absolute; top: 190px; width: 168px; padding: 10px 12px;
  background: rgba(10, 12, 5, .78); border: 2px solid rgba(255, 226, 60, .4);
  font-family: 'Galmuri11', monospace; font-size: 10px; color: #9fd8c8; letter-spacing: .5px; }
.tdeco-l .td-panel { left: 56px; } .tdeco-r .td-panel { right: 56px; }
.tdeco .td-row { display: flex; align-items: center; gap: 6px; margin: 7px 0; white-space: nowrap; }
.tdeco .td-row b { color: #ffe23c; font-weight: normal; }
.tdeco .td-bar { flex: 1; height: 7px; border: 1px solid #3d5a4e; background: #0a1410; overflow: hidden; }
.tdeco .td-bar i { display: block; height: 100%; width: var(--w, 50%);
  background: repeating-linear-gradient(90deg, #3ce86e 0 4px, transparent 4px 6px); animation: tdbar 2.2s steps(8) infinite alternate; }
.tdeco .td-bar-warn i { background: repeating-linear-gradient(90deg, #ffb054 0 4px, transparent 4px 6px); }
.tdeco .td-bar-red i { background: repeating-linear-gradient(90deg, #ff5d5d 0 4px, transparent 4px 6px); }
@keyframes tdbar { from { filter: brightness(.75); } to { filter: brightness(1.25); } }
.tdeco .td-term2 { top: 340px; }
.tdeco .td-hex { position: absolute; top: 470px; width: 54px; height: 54px;
  background: conic-gradient(from 0deg, #ff9435, #ffe23c, #ff9435);
  clip-path: polygon(30% 0, 70% 0, 100% 30%, 100% 70%, 70% 100%, 30% 100%, 0 70%, 0 30%);
  animation: hexspin 9s steps(24) infinite; opacity: .8; }
.tdeco-l .td-hex { left: 116px; } .tdeco-r .td-hex { right: 116px; }
@keyframes hexspin { to { transform: rotate(1turn); } }
.tdeco::after { content: ''; position: absolute; top: 0; bottom: 0; left: 0; right: 0; pointer-events: none;
  background-image: radial-gradient(rgba(255, 226, 60, .12) 1.5px, transparent 1.5px);
  background-size: 26px 26px; }
@media (min-width: 1900px) { .tdeco { display: block; } }
@media (min-width: 2560px) {
  .tdeco { width: 300px; }
  .tdeco .td-stripes { width: 26px; }
  .tdeco .td-vtext { font-size: 16px; top: 40px; }
  .tdeco-l .td-vtext { left: 48px; } .tdeco-r .td-vtext { right: 48px; }
  .tdeco .td-term { font-family: 'Galmuri14', 'Galmuri11', sans-serif; font-size: 14px; top: 76px; }
  .tdeco-l .td-term { left: 78px; } .tdeco-r .td-term { right: 78px; }
  .tdeco .td-panel { top: 250px; width: 220px; font-size: 11px; padding: 14px 16px; }
  .tdeco-l .td-panel { left: 74px; } .tdeco-r .td-panel { right: 74px; }
  .tdeco .td-term2 { top: 430px; }
  .tdeco .td-hex { top: 600px; width: 68px; height: 68px; }
  .tdeco-l .td-hex { left: 152px; } .tdeco-r .td-hex { right: 152px; }
  .tdeco .td-sprite { width: 250px; }
  .tdeco .td-sprite2 { width: 160px; bottom: 420px; }
  .tdeco-l .td-sprite2 { left: 120px; } .tdeco-r .td-sprite2 { right: 120px; }
}

/* ---------- 초대형 화면 (4K, 2560px+) — 중앙 콘텐츠 확대 ---------- */
@media (min-width: 2560px) {
  #title-inner { max-width: min(2360px, 96vw); }
  #title-logo .kr { font-size: clamp(76px, 4vw, 150px); }
  #title-logo .sub { font-size: 26px; }
  .section-label { font-size: 22px; margin: 38px 0 18px; }
  .map-card { padding: 20px 20px 22px; }
  .map-card img { height: clamp(240px, 26vh, 340px); }
  .map-card .mc-name { font-size: 30px; }
  .map-card .mc-sub { font-size: 18px; }
  .map-card .mc-boss { font-size: 17px; }
  .mc-diff { font-family: 'Galmuri14', 'Galmuri11', sans-serif; font-size: 14px; }
  #callsign { font-size: 24px; max-width: 720px; }
  #unit-row { grid-template-columns: repeat(6, 1fr); gap: 18px; }
  .unit-card canvas { width: 110px; height: 120px; }
  .unit-card .uc-band { font-size: 22px; padding: 12px 16px; }
  .unit-card .uc-band .tag { font-family: 'Galmuri14', 'Galmuri11', sans-serif; font-size: 14px; }
  .unit-card .uc-pilot { font-size: 17px; }
  .unit-card .uc-desc { font-family: 'Galmuri14', 'Galmuri11', sans-serif; font-size: 14px; }
  .unit-card .uc-weapon { font-family: 'Galmuri14', 'Galmuri11', sans-serif; font-size: 14px; }
  #copyright { font-size: 17px; }
  #upgrade-title { font-size: 64px; }
  #upgrade-sub { font-size: 20px; }
  #upgrade-cards { gap: 34px; }
  .up-band { font-size: 18px; }
  .up-icon img { width: 160px; height: 160px; }
  .up-name { font-size: 30px; }
  .up-sub { font-size: 16px; }
  .up-desc { font-size: 17px; min-height: 56px; }
  .up-btn { font-size: 21px; }
  #btn-up-pass { font-size: 21px; }
}
#visit-chip {
  display: inline-block; font-family: 'Galmuri11', monospace; font-size: 11px;
  color: var(--green); background: rgba(10, 12, 5, .75); border: 2px solid var(--line2);
  padding: 3px 12px; cursor: pointer; letter-spacing: 1px;
}
#visit-chip:hover { border-color: var(--cyan); color: var(--cyan); }

/* ---------- 채팅 ---------- */
#build-ver { position: fixed; left: 12px; bottom: 152px; z-index: 64; font-size: 11px; color: var(--dim);
             font-family: 'Galmuri11', monospace; pointer-events: none; padding: 2px 8px;
             background: rgba(10, 12, 5, .6); border: 1px solid var(--line2); }
body.in-game #build-ver { bottom: 200px; }
/* ---------- 우하단 레일 — 곡제목/웨이브/미니맵을 세로 스택 (간격 8px 통일) ---------- */
#right-rail { position: fixed; right: 12px; bottom: 12px; z-index: 44; display: none;
              flex-direction: column; align-items: flex-end; gap: 8px; }
body.in-game #right-rail { display: flex; }
/* 현재 재생 곡 제목 */
#np-title { display: none; max-width: 220px;
            padding: 4px 10px; border: 2px solid var(--line2);
            background: rgba(10, 12, 5, .78); color: var(--yellow); font-size: 11px;
            white-space: nowrap; overflow: hidden; text-overflow: ellipsis; pointer-events: auto;
            letter-spacing: 1px; cursor: pointer; }
#np-title:hover { border-color: var(--yellow); }
#np-title:active { transform: translateY(1px); }
body.in-game #np-title:not(.hidden) { display: block; }
#minimap { display: none;
           border: 2px solid var(--line);
           box-shadow: 4px 4px 0 rgba(0, 0, 0, .4); image-rendering: pixelated; }
body.in-game #minimap { display: block; }
#minimap.ui-fade { opacity: .25; }
/* 다음 웨이브 정보 */
#wave-info { display: none;
  align-items: center; gap: 8px; padding: 5px 10px 5px 6px; cursor: pointer;
  background: rgba(10, 12, 5, .85); border: 2px solid var(--line2);
  box-shadow: 3px 3px 0 rgba(0, 0, 0, .4); }
#wave-info:hover { border-color: var(--orange); }
body.in-game #wave-info { display: flex; }
#wave-info.ui-fade { opacity: .25; }
#wave-info.hidden { display: none !important; }
#wave-img { width: 44px; height: 44px; object-fit: contain; image-rendering: pixelated;
  background: #0d130d; border: 2px solid var(--line); }
#wave-name { font-size: 11px; color: #fff; white-space: nowrap; }
#boss-next { margin-top: 1px; font-family: 'Galmuri11', monospace; font-size: 11px; }
#chat-dim { position: fixed; inset: 0; z-index: 61; background: rgba(13, 10, 24, .72); }
#chat-wrap { position: fixed; left: 10px; z-index: 63; }
#chat-fab { position: relative; }
#chat-badge {
  position: absolute; top: -2px; right: -2px; min-width: 20px; height: 20px; line-height: 16px;
  background: var(--red); color: #fff; font-size: 11px; border: 2px solid var(--ink);
  text-align: center; padding: 0 3px;
}
/* 접속자 수 — 버튼 왼쪽 아래 초록 미니 뱃지 */
#chat-online-fab {
  position: absolute; bottom: -2px; left: -2px; min-width: 20px; height: 20px; line-height: 16px;
  background: var(--green); color: #06210f; font-size: 11px;
  border: 2px solid var(--ink); text-align: center; padding: 0 3px;
}
#chat-panel {
  position: absolute; left: 0; bottom: 46px; width: min(88vw, 340px);
  display: flex; flex-direction: column; overflow: hidden;
}
/* 게임 중엔 채팅창이 메인 버튼(154~194px) 위쪽에 열리도록 올림 */
body.in-game #chat-panel { bottom: 94px; }
#chat-head {
  display: flex; align-items: center; gap: 8px; padding: 8px 12px;
  background: rgba(21, 16, 36, .6); border-bottom: 2px solid var(--ink);
  font-size: 11px; color: var(--yellow);
}
#chat-online { margin-left: auto; font-family: 'Galmuri11', monospace; font-size: 10px; color: var(--green); }
#chat-close {
  background: none; border: none; color: var(--cream); font-size: 18px; line-height: 1;
  padding: 0 2px; cursor: pointer;
}
#chat-log {
  height: 200px; overflow-y: auto; padding: 8px 10px;
  font-family: 'Galmuri11', monospace; font-size: 11px; line-height: 1.5;
}
.chat-msg { padding: 2px 0; border-bottom: 1px dashed rgba(255, 255, 255, .08); word-break: break-word; }
.chat-msg .cm-t { color: #6b6088; font-size: 10px; }
.chat-msg .cm-n { color: var(--cyan); }
.chat-msg .cm-x { color: #e8e4f4; }
.chat-sys { color: #9d93c4; font-style: italic; }
#chat-input-row { display: flex; gap: 6px; padding: 8px; border-top: 2px solid var(--ink); background: rgba(21, 16, 36, .6); }
#chat-input-row input {
  font-family: inherit; font-size: 11px; padding: 6px 9px;
  border: 2px solid var(--line); background: #0a0e06; color: var(--green);
}
#chat-name { width: 82px; flex-shrink: 0; }
#chat-msg { flex: 1; min-width: 0; }
#chat-send { padding: 6px 11px; font-size: 11px; flex-shrink: 0; }

/* ---------- 모바일 (모든 기본 규칙보다 뒤에 위치해야 함) ---------- */
@media (max-width: 920px) {
  #unit-row { grid-template-columns: repeat(2, minmax(150px, 1fr)); gap: 8px; }
  #map-row { gap: 8px; }
  .unit-card .uc-body { flex-direction: column; align-items: center; text-align: center; }
  /* 슬롯 — 좁은 화면에서 사이드 칼럼이 릴을 압박해 이미지 깨짐 → 세로 스택으로 재배치 */
  #slot-sheet { width: 96vw; }
  #slot-marquee { padding: 0 14px 12px; }
  #slot-sheet h2 { font-size: 22px; letter-spacing: 2px; }
  #slot-sheet h2 small { font-size: 8px; letter-spacing: 3px; }
  #slot-body { flex-direction: column; padding: 0 14px; }
  #slot-body::before, #slot-body::after { display: none; }
  #slot-main { gap: 10px; margin: 14px 0; }
  #slot-flow { height: 106px; }
  .flow-card { flex-basis: 66px; height: 82px; }
  #flow-track { height: 82px; margin-top: -41px; gap: 8px; }
  #slot-agenda { min-height: 52px; margin: 8px 0; padding: 6px 10px; gap: 10px; }
  #agenda-icon { width: 38px; height: 38px; }
  #agenda-name { font-family: 'Galmuri14', 'Galmuri11', sans-serif; font-size: 14px; }
  .agenda-tag { font-size: 7px; }
  #slot-vote { gap: 12px; padding: 10px 12px; }
  .magi { gap: 5px; }
  .magi-tag { font-size: 7px; letter-spacing: 1px; }
  .vote { width: min(90px, 27vw); height: min(90px, 27vw); font-family: 'Galmuri14', 'Galmuri11', sans-serif; font-size: 14px; letter-spacing: 1px; }
  .vres { font-size: 9px; }
  #slot-meters { gap: 6px; }
  #slot-meters span { font-size: 10px; padding: 5px 7px; overflow: hidden; }
  #slot-meters b { font-size: 11px; }

  #slot-tray { margin: 0 14px 4px; height: 26px; }
  #slot-status { font-family: 'Galmuri14', 'Galmuri11', sans-serif; font-size: 14px; min-height: 38px; padding: 6px 10px; }
  #slot-jackpot { font-size: clamp(20px, 5.5vw, 44px); }
}
@media (max-width: 720px) {
  /* HUD — 한 줄 컴팩트 스트립. 패널 자체는 터치 통과 → 조이스틱 조작 영역 확보 */
  #hud { padding: 4px 6px; }
  #hud-top { display: flex; gap: 5px; align-items: flex-start; }
  .hud-panel { pointer-events: none; padding: 5px 6px; }
  .hud-panel .cartoon-btn { pointer-events: auto; }
  #hud-top > .hud-panel:first-child { flex: 0 0 auto; width: min(46%, 210px); min-width: 0; }
  #hud-mid { flex: 1; min-width: 0; gap: 4px; align-items: center; }
  .hud-right { flex: 0 0 auto; width: min(30%, 118px); min-width: 0; overflow: hidden; }
  #sys-log { display: none; } /* 좁은 우측 패널에서 로그 텍스트가 겹쳐 깨지던 것 차단 */
  .hud-panel h3 { font-size: 9px; margin-bottom: 3px; letter-spacing: .5px; }
  #unit-name { font-size: 11px; text-shadow: 1.5px 1.5px 0 var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  #pilot-name, #map-name { display: none; }
  #level-text { font-size: 9px; }
  .bar { height: 13px; border-width: 2px; }
  .hud-panel .bar { margin-top: 3px; }
  .bar .txt { font-size: 9px; }
  .bar-tag { font-size: 9px; left: 4px; }
  #hud-mid > .hud-panel { padding: 4px 7px; }
  #clock { font-size: 16px; text-shadow: 1.5px 1.5px 0 var(--ink); }
  #kill-count { font-size: 9px; margin-top: 1px; }
  #cable-state { font-size: 9px; padding: 1px 5px; margin-top: 2px; border-width: 1.5px; white-space: nowrap; max-width: 100%; overflow: hidden; text-overflow: ellipsis; box-sizing: border-box; }
  /* 우측 패널 배터리 바 — 좁은 폭에서 '전원' 태그와 수치 텍스트가 겹치는 것 방지.
     패널 제목(POWER)이 이미 라벨 역할을 하므로 바 안 태그는 숨김 */
  .hud-right .bar .bar-tag { display: none; }
  /* 무기 칩 — 좁은 우측 패널에서 세로 깨짐 방지: 화면 하단 고정 가로 스트립으로 분리.
     좌우 여백은 채팅 FAB·디버그 버튼 영역 회피용. pointer-events는 부모 패널(none) 상속 */
  #weapon-list { position: fixed; left: 52px; right: 52px; bottom: calc(6px + env(safe-area-inset-bottom, 0px));
                 flex-direction: row; flex-wrap: wrap; gap: 3px; justify-content: center; margin-top: 0; z-index: 35; }
  .weapon-chip { font-size: 9px; padding: 1px 5px; border-width: 1.5px; }
  .weapon-chip b { font-size: 8px; padding: 0 3px; }
  #sys-log { font-size: 9px; padding: 1px 6px; margin-top: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; box-sizing: border-box; }
  .hud-btns { margin-top: 4px; }
  .hud-btns .cartoon-btn { font-size: 10px; padding: 3px 6px; }
  /* 보스바·경고 배너 — HUD 스트립과 겹치지 않게 별도 고정 위치 */
  #boss-hud { position: fixed; left: 50%; translate: -50% 0; top: calc(112px + env(safe-area-inset-top, 0px)); width: min(84vw, 340px); padding: 5px 10px; }
  #alert-banner { position: fixed; left: 50%; translate: -50% 0; top: 30%; font-size: clamp(16px, 5.5vw, 24px); padding: 6px 16px; white-space: nowrap; }
  /* 강화 카드 — 스크롤 없이 3장 전부 보이는 컴팩트 행 레이아웃 */
  #upgrade-inner { padding: 8px 6px; }
  #upgrade-title { font-size: clamp(19px, 6vw, 26px); margin-bottom: 2px; }
  #upgrade-sub { font-size: 11px; margin-bottom: 8px; }
  #upgrade-cards { grid-template-columns: 1fr; justify-items: center; gap: 7px; }
  #upgrade-cards .up-card:nth-child(4):last-child { grid-column: auto; }
  .up-card {
    position: relative; width: min(94vw, 430px); padding-top: 20px;
    display: flex; align-items: center; text-align: left;
    box-shadow: 4px 4px 0 rgba(0, 0, 0, .5);
  }
  .up-card .up-band { position: absolute; top: 0; left: 0; right: 0; font-size: 9px; padding: 2px 8px; border-bottom-width: 2px; }
  .up-card .up-icon { padding: 4px 6px 4px 8px; }
  .up-card .up-icon img { width: 44px; height: 44px; border-width: 2px; }
  .up-card .up-txt { flex: 1; min-width: 0; padding: 4px 4px 6px 2px; }
  .up-card .up-name { font-family: 'Galmuri14', 'Galmuri11', sans-serif; font-size: 14px; padding: 0; }
  .up-card .up-sub { font-size: 10px; margin: 1px 0; }
  .up-card .up-desc { font-size: 10px; line-height: 1.3; padding: 0; min-height: 0; }
  .up-card .up-btn { flex: 0 0 auto; align-self: center; margin: 0 8px 0 4px; padding: 8px 12px; font-size: 11px; }
  .up-card .up-tag { display: none; } /* 행 레이아웃에서 선택 버튼과 충돌 — 밴드가 동일 정보 표기 */
  #result-grid { grid-template-columns: repeat(2, 1fr); }
  /* 모바일 한 화면 수렴 — 타이틀·간격·카드 전부 축소 */
  #title-inner { padding: 8px 8px 12px; }
  #title-logo .kr { font-size: clamp(28px, 8vw, 38px); }
  #title-logo .sub { font-size: 10px; letter-spacing: 1.5px; margin-top: 2px; }
  #title-logo .stripe { height: 5px; margin-top: 4px; }
  .section-label { font-size: 10px; margin: 9px 0 5px; letter-spacing: 1px; }
  .section-label::before, .section-label::after { max-width: 90px; }
  #map-row { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 5px; }
  .map-card { padding: 6px 6px 8px; min-width: 0; }
  .map-card img { height: 62px; border-width: 2px; }
  .map-card .mc-name { font-size: 11px; margin-top: 4px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .map-card .mc-sub { font-size: 8px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .mc-diff { font-size: 8px; padding: 0 5px; border-width: 1px; }
  .mc-boss { font-size: 8px; padding: 1px 6px; margin-top: 3px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%; }
  #callsign { font-size: 11px; width: auto; flex: 1; min-width: 0; padding: 6px 9px; }
  #unit-row { gap: 5px; }
  .map-card img, .unit-card canvas { image-rendering: pixelated; }
  .unit-card { padding: 0; }
  .unit-card .uc-body { flex-direction: row; align-items: flex-start; text-align: left; padding: 6px 7px; gap: 7px; }
  .unit-card canvas { width: 44px; height: 50px; flex-shrink: 0; }
  .unit-card .uc-pilot { font-size: 9px; }
  .unit-card .uc-desc { font-size: 8px; line-height: 1.3; }
  .unit-card .uc-weapon { font-size: 8px; }
  .unit-card .uc-band { font-size: 11px; padding: 6px 9px; flex-wrap: wrap; gap: 3px; }
  .unit-card .uc-band .tag { font-size: 8px; }
  /* 상단 카드 우측 끝 — '선택됨' 뱃지가 카드 밖으로 나가 잘리지 않게 카드 안쪽으로 */
  .map-card.sel::after { top: 4px; right: 4px; }
  #hud-mid { min-width: 0; }
  .hud-right { overflow: hidden; }
  #copyright { font-size: 9px; margin-top: 6px; }
  #visit-row { margin-top: 5px; }
  #patch-board { margin-top: 12px; }
  .pb-head { font-size: 8px; padding: 6px 10px 3px; }
  .pb-sub { font-size: 6px; }
  .pb-list { max-height: 120px; padding: 3px 10px 8px; }
  .pb-ver { font-size: 8px; min-width: 52px; }
  .pb-item { font-size: 11px; }
  #chat-panel { width: min(92vw, 340px); bottom: 52px; }
  body.in-game #chat-panel { bottom: 100px; } /* 메인 버튼 위쪽 */
  /* 좌하단 버튼 스택 — 모바일은 전부 동일한 42px 원형 아이콘 */
  #fab-col { left: 8px; bottom: calc(8px + env(safe-area-inset-bottom, 0px)); gap: 6px; }
  #fab-col .cartoon-btn, #btn-main-fab {
    min-width: 0; width: 42px; height: 42px; padding: 0; font-size: 0;
    display: inline-flex; align-items: center; justify-content: center;
  }
  #btn-main-fab { left: 8px; bottom: calc(152px + env(safe-area-inset-bottom, 0px)); display: none; } /* 메인 화면에선 숨김 유지 */
  body.in-game #btn-main-fab { display: inline-flex; }
  #btn-main-fab::before { content: '🏠'; font-size: 18px; line-height: 1; }
  #btn-rank::before { content: '🏆'; font-size: 18px; line-height: 1; }
  #btn-settings2::before { content: '\2699\FE0F'; font-size: 18px; line-height: 1; }
  #chat-wrap { left: 8px; bottom: calc(104px + env(safe-area-inset-bottom, 0px)); }
  #chat-fab {
    min-width: 0; width: 42px; height: 42px; padding: 0; font-size: 0;
    display: inline-flex; align-items: center; justify-content: center;
  }
  #chat-fab::before { content: '💬'; font-size: 18px; line-height: 1; }
  /* v0.2.11 — 버튼 기능별 색상 분리: 전부 같은 녹색이라 구분 불가했음.
     랭킹=금(트로피), 설정=청(중립), 채팅=녹색 유지, 메인=적색 유지. 아이콘도 18→21px */
  #btn-rank { background: linear-gradient(180deg, #ffd88a 0 50%, var(--orange) 50%); color: #201604; }
  #btn-settings2 { background: linear-gradient(180deg, #a8c8ff 0 50%, #5c8ce8 50%); color: #0a1a3a; }
  #fab-col .cartoon-btn::before, #btn-main-fab::before, #chat-fab::before { font-size: 21px; }
  /* v0.2.12 — 아이콘 중앙 정렬: 데스크톱용 gap 7px+letter-spacing이 아이콘을 좌측으로 밀었음.
     모바일 아이콘 버튼에서는 간격 제거해 ::before가 정중앙에 오도록 */
  #fab-col .cartoon-btn, #btn-main-fab, #chat-fab { gap: 0; letter-spacing: 0; }
  /* 이모지 글리프는 폰트 베이스라인 메트릭 때문에 4~6px 아래로 그려짐 — 이모지 폰트를 명시해
     라인박스 메트릭을 맞추고 2.5px 보정 (Windows Segoe 기준 실측, 타 플랫폼도 유사) */
  #fab-col .cartoon-btn::before, #btn-main-fab::before, #chat-fab::before {
    font-family: 'Segoe UI Emoji', 'Noto Color Emoji', 'Apple Color Emoji', sans-serif;
    transform: translateY(-2.5px);
  }
  /* 집 이모지는 글리프가 어드밴스 박스 왼쪽에 치우쳐 그려져(실측 -4px) 개별 보정 */
  #btn-main-fab::before { transform: translate(4px, -2.5px); }
  #build-ver { left: 8px; bottom: calc(150px + env(safe-area-inset-bottom, 0px)); }
  body.in-game #build-ver { bottom: calc(198px + env(safe-area-inset-bottom, 0px)); }
  #right-rail { right: 8px; bottom: calc(8px + env(safe-area-inset-bottom, 0px)); gap: 6px; }
  #minimap { width: 96px; height: 96px; }
  #wave-info { padding: 4px 8px 4px 4px; gap: 6px; }
  #wave-img { width: 36px; height: 36px; }
  #wave-name { font-size: 10px; }
  #boss-next { font-size: 10px; }
  #np-title { max-width: 160px; font-size: 10px; }
  /* 좁은 카드에서 밴드 텍스트+태그 겹침 방지 */
  .unit-card .uc-band { font-family: 'Galmuri14', 'Galmuri11', sans-serif; font-size: 14px; padding: 6px 9px; flex-wrap: wrap; gap: 3px; }
  .unit-card .uc-band .tag { font-size: 9px; padding: 1px 6px; }
}

@media (max-width: 520px) {
  /* 결과 시트 압축 — 모바일 세로에서 스크롤 없이 한 화면에 표시 (행 수는 pageSize()가 뷰포트 높이로 조정) */
  .sheet.result { padding: 10px 10px; width: 96vw; }
  .sheet.result h2 { font-size: 15px; margin-bottom: 7px; padding-bottom: 5px; letter-spacing: 1px; }
  #result-grid { gap: 5px; margin-bottom: 8px; }
  .res-cell { padding: 4px 2px; border-width: 1.5px; }
  .res-cell b { font-size: 16px; }
  .res-cell span { font-size: 9px; letter-spacing: 0; }
  .name-row { margin-bottom: 5px; gap: 5px; }
  #score-name { padding: 5px 8px; font-size: 12px; }
  .name-row .cartoon-btn { font-size: 10px; padding: 4px 7px; white-space: nowrap; }
  #score-status { min-height: 13px; font-size: 10px; margin-bottom: 3px; }
  table.score { font-size: 10px; }
  table.score th { padding: 2px; font-size: 10px; border-bottom-width: 1.5px; }
  table.score td { padding: 2px 1px; }
  table.score .map-sub, .map-sub { font-size: 9px; }
  .pager { margin-top: 4px; min-height: 20px; gap: 5px; }
  .pager .pager-btn { padding: 2px 8px; font-size: 10px; }
  .pager .pg-info { font-size: 10px; min-width: 70px; }
  .sheet.result .foot { margin-top: 7px !important; }
  .sheet.result .foot .cartoon-btn { font-size: 11px; padding: 5px 9px; }

  /* 초소형 화면 — HUD를 더 조밀하게 */
  .hud-panel h3 { font-size: 8px; }
  #unit-name { font-size: 11px; }
  .bar { height: 13px; }
  .bar .txt { font-size: 9px; font-family: 'Galmuri9', 'Press Start 2P', monospace; }
  #clock { font-family: 'Galmuri11', monospace; font-size: 11px; }
  .weapon-chip { font-size: 8px; padding: 1px 4px; }
  #sys-log { font-size: 8px; }
}

/* 모바일 가로 모드 등 세로가 좁은 화면 — 스트립 레이아웃 + 최대한 납작하게 (맨 끝: 우선 적용) */
@media (max-height: 480px) {
  #hud { padding: 3px 5px; }
  #hud-top { display: flex; gap: 5px; align-items: flex-start; }
  .hud-panel { pointer-events: none; padding: 3px 6px; }
  .hud-panel .cartoon-btn { pointer-events: auto; }
  #hud-top > .hud-panel:first-child { flex: 0 0 auto; width: min(42%, 190px); min-width: 0; }
  #hud-mid { flex: 0 0 auto; gap: 3px; }
  .hud-right { flex: 1; min-width: 0; }
  .hud-panel h3 { font-size: 8px; margin-bottom: 1px; }
  .hud-panel h3 .tag { display: none; }
  #unit-name { font-size: 10px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  #pilot-name, #map-name, #sys-log { display: none; }
  .bar { height: 13px; border-width: 2px; }
  .hud-panel .bar { margin-top: 2px; }
  .bar .txt { font-size: 9px; font-family: 'Galmuri9', 'Press Start 2P', monospace; }
  .bar-tag { font-size: 9px; }
  #clock { font-family: 'Galmuri11', monospace; font-size: 11px; }
  #kill-count { font-size: 8px; margin-top: 0; }
  #cable-state { font-size: 8px; padding: 1px 4px; border-width: 1.5px; }
  #weapon-list { flex-direction: row; flex-wrap: wrap; gap: 2px; margin-top: 2px; }
  .weapon-chip { font-size: 8px; padding: 1px 4px; border-width: 1.5px; }
  .weapon-chip b { font-size: 7px; padding: 0 3px; }
  .hud-btns { margin-top: 2px; }
  .hud-btns .cartoon-btn { font-size: 9px; padding: 2px 5px; }
  #boss-hud { position: fixed; left: 50%; translate: -50% 0; top: calc(48px + env(safe-area-inset-top, 0px)); width: min(70vw, 320px); }
  #alert-banner { position: fixed; left: 50%; translate: -50% 0; top: 26%; font-size: clamp(14px, 4vw, 22px); padding: 5px 14px; white-space: nowrap; }
}


/* 캐릭터가 UI 밑으로 들어갈 때 반투명 */
#hud-top .hud-panel, #boss-hud, #alert-banner, #visit-row, #chat-wrap, #joystick, #minimap, #np-title, #btn-main-fab, #fab-col { transition: opacity .18s ease; }
.ui-fade { opacity: .22 !important; }

/* ==================== 타이틀 재설계: 출격 통제소 (v0.2.0) ====================
   산재한 선택지를 STEP 01~03 출격 파이프라인으로 재구성. 파일 끝에 위치해 동일 특이도 규칙을 덮어씀 */
#title-status {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  font-size: 11px; color: var(--dim); letter-spacing: 1px;
  border: 2px solid var(--line2); background: rgba(8, 10, 5, .72);
  padding: 5px 12px; margin-bottom: 12px; white-space: nowrap;
}
.ts-side { flex-shrink: 0; display: inline-flex; align-items: center; }
.ts-led {
  display: inline-block; width: 7px; height: 7px; margin-right: 7px;
  background: var(--green); box-shadow: 0 0 7px rgba(108, 232, 95, .8);
  animation: ts-led-blink 1.8s steps(2, start) infinite;
}
@keyframes ts-led-blink { 50% { opacity: .25; } }
.ts-ticker { flex: 1; min-width: 0; text-align: center; color: #9fb89f; overflow: hidden; text-overflow: ellipsis; }
.ts-right { align-items: baseline; } /* inline-flex라 vertical-align 무력 — 플렉스 베이스라인 정렬 사용 */
.ts-right b { color: var(--green); font-weight: normal; font-family: 'Galmuri9', 'Press Start 2P', 'Galmuri11', monospace; font-size: 9px; transform: translateY(1px); } /* Press Start 베이스라인이 1px 높음 — 실측 보정 */

/* 로고 — 한 줄 락업으로 축소, 선택 파이프라인이 주연 */
#title-logo .kr { font-size: clamp(30px, 4vw, 54px); }
#title-logo .sub { font-size: 11px; letter-spacing: 2px; }
#title-logo .stripe { height: 6px; margin-top: 6px; }
#title-logo { margin-bottom: 2px; }

/* STEP 라벨 — 번호 칩 + 해저드 라인 */
.section-label { display: flex; align-items: center; gap: 10px; margin: 16px 0 9px; text-align: left; }
.section-label::before { display: none; }
.section-label::after {
  content: ''; position: static; transform: none; flex: 1; height: 6px; max-width: none;
  background: repeating-linear-gradient(45deg, rgba(255, 196, 77, .45) 0 9px, transparent 9px 18px);
}
.step-num {
  font-family: 'Galmuri9', 'Press Start 2P', monospace; font-size: 9px; color: #151005;
  background: var(--yellow); padding: 4px 7px 3px; border: 2px solid var(--ink);
  box-shadow: 2px 2px 0 rgba(0, 0, 0, .45); flex-shrink: 0;
}
.step-txt { font-family: 'Galmuri14', 'Galmuri11', sans-serif; font-size: 14px; color: #fff; letter-spacing: 1px; flex-shrink: 0; }
.step-hint { font-size: 11px; color: var(--dim); flex-shrink: 0; }

/* STEP 01 — 슬림 가로형 지역 카드 */
#map-row { gap: 12px; }
.map-card { display: flex; align-items: stretch; gap: 10px; padding: 7px; text-align: left; }
.map-card img { width: 128px; height: 76px; flex-shrink: 0; align-self: center; }
.mc-info { flex: 1; min-width: 0; display: flex; flex-direction: column; justify-content: center; gap: 3px; }
.map-card .mc-name { font-family: 'Galmuri14', 'Galmuri11', sans-serif; font-size: 14px; margin-top: 0; }
.map-card .mc-sub { font-size: 11px; margin-top: 0; }
.mc-boss { margin-top: 0; }
.mc-diff { vertical-align: 1px; }
/* 클리어런스 등급 — 어려움은 점멸 적색 경고 */
.mc-diff.diff-hard { animation: diff-warn 1.1s steps(2, start) infinite; }
@keyframes diff-warn { 50% { opacity: .35; } }
.map-scroll-hint { display: none; }

/* STEP 03 — 기체 카드: 스프라이트 확대 + 스탯 바 + 출격 오버레이 */
.unit-card { position: relative; }
.unit-card canvas { width: 102px; height: 114px; }
.uc-info { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.uc-stats { display: flex; flex-direction: column; gap: 3px; margin: 4px 0 2px; }
.uc-stat { display: flex; align-items: center; gap: 6px; }
.uc-stat span { font-family: 'Galmuri9', 'Press Start 2P', monospace; font-size: 7px; color: var(--dim); width: 24px; flex-shrink: 0; }
.uc-stat i { flex: 1; height: 6px; background: #090c06; border: 1px solid var(--line2); display: block; }
.uc-stat i b { display: block; height: 100%; }
.uc-stat i b.hp { background: #ff6b5e; }
.uc-stat i b.at { background: #6fe8ff; }
.uc-stat i b.sp { background: #ffc44d; }
.unit-card .uc-desc { order: 4; }
.uc-deploy {
  position: absolute; inset: 0; z-index: 3; display: flex; align-items: center; justify-content: center;
  background: rgba(6, 8, 5, .74); opacity: 0; pointer-events: none; transition: opacity .13s;
}
.uc-deploy span {
  font-family: 'Galmuri14', 'Galmuri11', sans-serif; font-size: 14px; letter-spacing: 8px; color: var(--green);
  border: 2px solid var(--green); padding: 9px 14px 9px 22px; background: rgba(8, 12, 6, .92);
  box-shadow: 0 0 18px rgba(108, 232, 95, .35);
}
.unit-card:hover .uc-deploy, .unit-card:focus-visible .uc-deploy { opacity: 1; }

/* 하단 터미널 스트립 — 플로팅 FAB를 대체하는 명령 행 */
#title-term { display: flex; justify-content: center; align-items: center; gap: 8px 20px; flex-wrap: wrap; margin-top: 24px; }
.term-btn {
  background: none; border: none; cursor: pointer; padding: 7px 2px;
  font-family: 'Galmuri11', sans-serif; font-size: 11px; color: var(--dim); letter-spacing: 2px;
}
.term-btn::before { content: '[ '; color: var(--line2); }
.term-btn::after { content: ' ]'; color: var(--line2); }
.term-btn:hover, .term-btn:focus-visible { color: var(--green); text-shadow: 0 0 8px rgba(108, 232, 95, .5); }
.term-btn:hover::before, .term-btn:hover::after, .term-btn:focus-visible::before, .term-btn:focus-visible::after { color: var(--green); }
.term-btn:focus-visible { outline: 2px solid var(--green); outline-offset: 1px; }
#title-term #visit-chip { margin-left: 6px; }

/* 타이틀에선 플로팅 버튼 숨김 — 터미널 스트립이 대체 (채팅은 레이아웃 유지 위해 visibility) */
body:not(.in-game) #fab-col { display: none; }
body:not(.in-game) #chat-fab { visibility: hidden; }

/* 모바일 스티키 출격 바 — 기본 숨김, 모바일+타이틀에서만 */
#sortie-bar { display: none; }

@media (prefers-reduced-motion: reduce) {
  .ts-led, .mc-diff.diff-hard { animation: none; }
  .uc-deploy { transition: none; }
}

/* ---------- 모바일 스텝 플로우 (파일 끝 — 기존 미디어쿼리를 덮어씀) ---------- */
@media (max-width: 720px) {
  #title-inner { padding-bottom: 76px; } /* 스티키 바 공간 */
  #title-status { font-size: 9px; padding: 4px 8px; gap: 8px; margin-bottom: 8px; }
  .ts-ticker { font-size: 9px; }
  .ts-right b { font-size: 8px; }
  #title-logo .kr { font-size: clamp(24px, 7vw, 32px); }
  .section-label { margin: 12px 0 7px; gap: 7px; }
  .step-num { font-size: 7px; padding: 3px 5px 2px; }
  .step-txt { font-size: 11px; }
  .step-hint { display: none; } /* 모바일에선 힌트 생략 — 라벨 행 간소화 */

  /* 지역 선택 — 세로 스택 (v0.2.10: 캐러셀 폐기, 3개 지역이 한 화면에 모두 표시) */
  #map-row {
    display: flex; flex-direction: column; gap: 7px;
    margin: 0; padding: 2px 0 4px;
    flex-shrink: 0; /* title-inner column flex 안에서 수축 방지 */
  }
  .map-card { width: 100%; padding: 6px; box-sizing: border-box; }
  .map-card img { width: 84px; height: 54px; }
  .map-scroll-hint { display: none; }

  /* 기체 — 전폭 가로형 카드 (큰 터치 타겟) */
  #unit-row { grid-template-columns: 1fr; gap: 7px; }
  .unit-card canvas { width: 56px; height: 64px; }
  .uc-deploy span { font-size: 11px; letter-spacing: 5px; padding: 7px 10px 7px 16px; }

  /* 스티키 출격 바 */
  body:not(.in-game) #sortie-bar {
    display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 58;
    justify-content: space-between; align-items: center; gap: 10px;
    padding: 10px 12px calc(10px + env(safe-area-inset-bottom, 0px));
    background: rgba(7, 9, 4, .95); border-top: 2px solid var(--line);
    font-size: 11px; color: #cfe8cf; letter-spacing: .5px;
  }
  #sb-info { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  #sb-hint { flex-shrink: 0; font-size: 9px; color: var(--green); }

  /* 터미널 스트립 — 스티키 바 위에서 마지막 행 */
  #title-term { margin-top: 14px; gap: 6px 14px; }
  .term-btn { font-size: 11px; padding: 9px 2px; } /* 터치 타겟 확보 */
}

/* 초소형 — 카드 스프라이트 더 축소 */
@media (max-width: 520px) {
  .unit-card canvas { width: 48px; height: 56px; }
  .map-card img { width: 84px; height: 54px; }
}

/* 대화면 — 슬림 카드 유지하면서 간격만 */
@media (min-width: 2560px) {
  .map-card img { width: 190px; height: 112px; }
  .unit-card canvas { width: 128px; height: 142px; }
  .uc-stat span { font-size: 9px; width: 30px; }
  .uc-stat i { height: 8px; }
  .step-num { font-size: 12px; }
  .ts-right b { font-size: 12px; }
}

/* v0.2.0 미세 조정 — 초소형 화면 상태바 간소화 + 타이틀 버전 태그 위치 */
@media (max-width: 520px) {
  .ts-ticker { display: none; } /* 좁은 상태바에서 중간 생략 부호 대신 LED+SYNC만 */
  #title-status { justify-content: space-between; }
}
@media (max-width: 720px) {
  body:not(.in-game) #build-ver { bottom: calc(52px + env(safe-area-inset-bottom, 0px)); } /* 스티키 출격 바 위로 */
}

/* v0.2.0 flex 붕괴 수정 — 모바일 캐러셀: row(flex) > card(flex) 중첩에서 순환 크기 계산으로
   텍스트 행이 0으로 수축하던 문제. mc-info 자식의 수축을 막아 내용 크기를 보장 */
.mc-info > * { flex-shrink: 0; }
.mc-info { flex: 1 0 auto; }
.map-card img { flex-shrink: 0; }

/* v0.2.0 — 모바일 캐러셀에서 '선택됨' 배지가 난이도 칩과 겹침 → 녹색 아웃라인만으로 선택 표기 */
@media (max-width: 720px) {
  .map-card.sel::after { display: none; } /* 모바일은 배지 숨김 — 플랫 녹색 테두리로 선택 표기 */
}

/* ==================== v0.2.1 — 미리보기 디자인 정합 ====================
   세로형 기체 카드 6열 + 좌측 로고 락업/우측 수치 클러스터 + 스크롤 마퀴 + 분할 터미널 바 */

/* --- 헤더: 좌측 락업 + 우측 수치 --- */
#title-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 4px; }
#title-logo { text-align: left; margin-bottom: 0; }
#title-logo .kr {
  font-size: clamp(34px, 4.6vw, 62px); line-height: 1.1;
  color: transparent; -webkit-text-stroke: 2px #e8f0e8;
  text-shadow: none;
}
#title-logo .kr em { color: transparent; -webkit-text-stroke-color: var(--purple); }
#title-logo .sub { font-size: 11px; color: var(--yellow); letter-spacing: 2px; margin-top: 4px; }
#title-stats { display: flex; gap: 22px; flex-shrink: 0; padding-bottom: 4px; }
.tst { text-align: right; }
.tst label { display: block; font-size: 11px; color: var(--dim); letter-spacing: 1px; margin-bottom: 2px; }
.tst b { font-family: 'Galmuri14', 'Press Start 2P', 'Galmuri11', monospace; font-weight: normal; font-size: 14px; }
.tst b.cy { color: var(--cyan); }
.tst b.gn { color: var(--green); }
.tst b.yl { color: var(--yellow); }

/* --- 상태바 티커: 연속 마퀴 --- */
.ts-ticker.is-tape { overflow: hidden; white-space: nowrap; color: var(--orange); }
.tape-run { display: inline-block; white-space: nowrap; animation: tape-scroll 36s linear infinite; }
@keyframes tape-scroll { from { transform: translateX(0); } to { transform: translateX(-50%); } }

/* --- STEP 01: 난이도 칩을 카드 우상단 코너로 --- */
.map-card { position: relative; }
.mc-diff { position: absolute; top: 0; right: 0; margin-left: 0; z-index: 2; }
.mc-boss { margin-right: 52px; } /* 코너 칩과 겹침 방지 */

/* --- 파일럿 행: 우측 힌트 --- */
#callsign-row .cs-hint { font-size: 11px; color: var(--dim); letter-spacing: .5px; }

/* --- STEP 03: 세로형 기체 카드 6열 --- */
#unit-row { grid-template-columns: repeat(6, 1fr); gap: 10px; }
.unit-card { text-align: center; }
.uc-band { display: flex; justify-content: center; padding: 7px 6px 6px; border-bottom: 2px solid var(--ink); }
.uc-band .tag {
  font-family: 'Galmuri11', sans-serif; font-size: 11px; color: #fff; padding: 2px 10px;
  border: 2px solid var(--ink); margin: 0; white-space: nowrap;
}
.uc-body { display: flex; flex-direction: column; align-items: center; padding: 8px 8px 10px; gap: 6px; }
.unit-card canvas { width: 116px; height: 130px; }
.uc-info { display: flex; flex-direction: column; align-items: stretch; gap: 3px; width: 100%; }
.uc-name { font-family: 'Galmuri14', 'Galmuri11', sans-serif; font-size: 14px; color: #fff; text-align: center; }
.uc-pilot { text-align: center; }
.uc-stats { width: 100%; }
.uc-stat span { text-align: left; }
.unit-card .uc-weapon { text-align: center; margin-top: 3px; }
.unit-card .uc-desc { display: none; } /* 세로 카드에선 숨김 — 호버 오버레이에 표시 */
/* 출격 오버레이에 특성 설명 포함 */
.uc-deploy { flex-direction: column; gap: 10px; padding: 12px; }
.uc-deploy-desc {
  font-size: 11px; line-height: 1.5; color: #cfe8cf; letter-spacing: 0;
  max-width: 92%; text-align: center;
}

/* 중간 폭 — 3열 세로 카드 */
@media (min-width: 721px) and (max-width: 1100px) {
  #unit-row { grid-template-columns: repeat(3, 1fr); }
}

/* --- 하단 터미널 바: 전폭 분할 세그먼트 --- */
#title-term {
  display: flex; flex-wrap: nowrap; gap: 0; margin-top: 22px;
  border: 2px solid var(--line2); background: rgba(8, 10, 5, .72);
}
.term-btn {
  flex: 1; padding: 10px 4px; letter-spacing: 1px;
  border-right: 1px solid var(--line2);
}
.term-btn::before, .term-btn::after { content: none; }
.term-btn:hover { background: rgba(108, 232, 95, .08); }
#title-term #visit-chip { margin-left: 0; align-self: center; padding: 3px 10px; border-width: 0 0 0 1px; border-color: var(--line2); }

/* --- 모바일: 가로형 카드 유지 (기존 스텝 플로우) --- */
@media (max-width: 720px) {
  #title-head { flex-direction: column; align-items: flex-start; gap: 4px; }
  #title-stats { display: none; } /* 좁은 화면 — 상태바 티커가 같은 정보 */
  #title-logo .kr { font-size: clamp(20px, 6.4vw, 28px); -webkit-text-stroke-width: 1.5px; white-space: nowrap; }
  #unit-row { grid-template-columns: 1fr; }
  .unit-card { text-align: left; }
  .uc-body { flex-direction: row; align-items: flex-start; padding: 6px 7px; gap: 7px; }
  .unit-card canvas { width: 56px; height: 64px; }
  .uc-info { flex: 1; min-width: 0; align-items: stretch; }
  .uc-name { text-align: left; font-size: 14px; }
  .uc-pilot { text-align: left; }
  .unit-card .uc-weapon { text-align: left; }
  .unit-card .uc-desc { display: block; } /* 모바일은 카드 안에 표시 */
  .uc-deploy-desc { display: none; } /* 모바일은 desc가 카드에 있으니 중복 불필요 */
  #callsign-row .cs-hint { display: none; }
  /* 터미널 바 — 좁으면 2열 그리드 */
  #title-term { flex-wrap: wrap; }
  .term-btn { flex: 1 0 45%; border-top: 1px solid var(--line2); }
  #title-term #visit-chip { border-width: 1px 0 0; flex: 1 0 100%; text-align: center; padding: 6px; }
  /* 마퀴는 유지하되 속도 여유 */
}

/* reduced-motion — 마퀴 정지 */
@media (prefers-reduced-motion: reduce) {
  .tape-run { animation: none; }
}

/* 대화면 */
@media (min-width: 2560px) {
  #title-logo .kr { -webkit-text-stroke-width: 3px; }
  .tst b { font-size: 20px; }
  .tst label { font-size: 14px; }
  .unit-card canvas { width: 150px; height: 168px; }
}

/* v0.2.1 — 난이도 칩이 우상단으로 이동하면서 '선택됨' 배지와 충돌 → 배지를 좌상단으로 */
.map-card.sel::after { right: auto; left: 6px; top: auto; bottom: 6px; }
@media (max-width: 720px) {
  .map-card.sel::after { left: 4px; }
}

/* ==================== v0.2.2 — 피드백 수정 ====================
   ① 맵 선택/호버 효과 강화 ② 스텝 칩 색상 구분 ③ 파일럿 행 시안 정합 */

/* ① 맵 카드 — 호버: 들림+밝기+녹색 테두리 / 선택: 인광 녹색 글로우 */
.map-card { transition: transform .13s, filter .13s, box-shadow .13s; cursor: pointer; }
.map-card:hover {
  border-color: var(--cyan);
}
.map-card.sel {
  outline: none;
  border-color: var(--green);
  /* box-shadow는 clip-path 코너컷에 잘려 모서리가 끊겨 보임 → clip 형상을 따라가는 drop-shadow 필터로 글로우 */
  filter: drop-shadow(6px 6px 0 rgba(0, 0, 0, .5)) drop-shadow(0 0 5px rgba(87, 255, 158, .55));
}
/* 기체 카드 호버도 동일한 들림 피드백 (출격 오버레이와 병행) */
.unit-card { transition: transform .13s, filter .13s; }
.unit-card:hover { transform: translateY(-3px); filter: brightness(1.1); }

/* ② 스텝 칩 색상 구분 — 01 노랑(준비) / 02 시안(등록) / 03 적색(출격) */
.step-1 .step-num { background: var(--yellow); }
.step-2 .step-num { background: var(--cyan); }
.step-3 .step-num { background: #ff5d4e; color: #210805; }
.step-2.section-label::after { background: repeating-linear-gradient(45deg, rgba(111, 232, 255, .4) 0 9px, transparent 9px 18px); }
.step-3.section-label::after { background: repeating-linear-gradient(45deg, rgba(255, 93, 78, .45) 0 9px, transparent 9px 18px); }

/* ③ 파일럿 등록 — 시안 정합: 태그 칩 제거, 전폭 터미널 입력창 + 좌측 정렬 인광 텍스트 */
#callsign-row { flex-wrap: nowrap; gap: 12px; }
#callsign-row .tag { display: none; }
#callsign {
  flex: 1; max-width: none; text-align: left; padding: 9px 14px 9px 34px;
  font-family: 'Galmuri14', 'Galmuri11', sans-serif; font-size: 14px; color: var(--green);
  background: #070a04 url('') none; border: 2px solid var(--line);
  text-shadow: 0 0 7px rgba(108, 232, 95, .45); caret-color: var(--green);
  position: relative;
}
#callsign-row { position: relative; }
#callsign-row::before {
  content: '▸'; position: absolute; left: 13px; top: 50%; transform: translateY(-50%);
  color: var(--green); font-size: 14px; z-index: 1; pointer-events: none;
  text-shadow: 0 0 7px rgba(108, 232, 95, .6);
}
#callsign:focus { outline: none; border-color: var(--green); box-shadow: 0 0 14px rgba(108, 232, 95, .28); }
#callsign::placeholder { color: var(--dim); text-shadow: none; }
#callsign-row .cs-hint { flex-shrink: 0; align-self: center; }
@media (max-width: 720px) {
  #callsign { font-size: 11px; padding: 8px 10px 8px 28px; }
  #callsign-row::before { font-size: 11px; left: 10px; }
}

/* v0.2.5 — 코너컷 clip-path 제거: 깎인 모서리가 선택 테두리와 함께 끊겨 보이는 문제.
   시안대로 직각 하드엣지로 통일 (drop-shadow는 사각 형상을 그대로 따라감) */
.map-card, .unit-card { clip-path: none; }

/* v0.2.6 — 기체 호버: 기체색(--uc, renderUnitStats가 주입) 테두리+글로우. 오버레이는 시안대로 밝게 */
.unit-card:hover {
  border-color: var(--uc, var(--green));
  filter: drop-shadow(6px 6px 0 rgba(0, 0, 0, .5)) drop-shadow(0 0 7px var(--uc, rgba(87, 255, 158, .6)));
}
.uc-deploy { background: rgba(6, 8, 5, .52); } /* 시안 — 아래 스프라이트·콘텐츠가 읽히는 밝기 */
.uc-deploy span { font-size: 11px; letter-spacing: 5px; padding: 6px 10px 6px 15px; }

/* v0.2.7 — 4K 사이드 장식 정리: 가짜 계기판(바 패널·단말 텍스트·헥스)은 타이틀 자체 상태바/수치와
   중복되는 소음이고, 96vw 콘텐츠와 겹쳐 지저분해 보였음. 해저드 스트라이프+세로 직함 문자만 남긴
   최소 프레임 — 콘텐츠 여백(양쪽 100px+) 안에 들어가 겹침 없음. 장식 요소는 포인터 이벤트 없음 */
.tdeco { opacity: .65; }
.tdeco .td-panel, .tdeco .td-term, .tdeco .td-term2, .tdeco .td-hex { display: none; }
.tdeco .td-vtext { letter-spacing: 6px; opacity: .8; }

/* v0.2.8 — 버전 표시를 상태바 우측 인라인으로 이동. 플로팅 #build-ver는 전폭 패치 게시판과
   겹쳐서 타이틀에서는 숨김(인게임에서는 그대로 표시) */
.ts-ver { color: var(--dim); font-size: inherit; opacity: .75; margin-left: 8px; } /* 인라인 배치 — SYNC 라벨과 같은 폰트·크기라 베이스라인 일치 */
body:not(.in-game) #build-ver { display: none; }

/* v0.2.16 — 스켈레톤 로딩: 썸네일·기체 프리뷰·방문 수치가 로드되는 동안 MAGI 스캔 연출.
   인광 스캔 밴드 + 스캔라인 텍스처 — 로드 완료 시 JS가 클래스 제거 */
.skel { background-color: #070a05;
  background-image: linear-gradient(100deg, transparent 25%, rgba(87, 255, 158, .14) 50%, transparent 75%),
    repeating-linear-gradient(0deg, rgba(87, 255, 158, .07) 0 1px, transparent 1px 3px);
  background-size: 240% 100%, 100% 100%; background-repeat: no-repeat, repeat;
  animation: skel-scan 1.3s linear infinite; }
@keyframes skel-scan { 0% { background-position: 200% 0, 0 0; } 100% { background-position: -100% 0, 0 0; } }
.skel-inline { display: inline-block; width: 3ch; height: .8em; background-color: #070a05;
  background-image: linear-gradient(100deg, transparent 25%, rgba(87, 255, 158, .22) 50%, transparent 75%);
  background-size: 240% 100%; background-repeat: no-repeat; animation: skel-scan 1.3s linear infinite; }
@media (prefers-reduced-motion: reduce) { .skel, .skel-inline { animation: none; } }

/* ==================== v0.2.37 — 모바일 타이틀 단일 화면화 (제안 A 적용) ====================
   세로 스택 전폭 카드 폐기 — 지역 가로 3분할 칩 + 기체 2열×3행 컴팩트 그리드.
   스크롤 없이 한 화면에서 지역·기체 선택과 출격이 가능해야 한다. */
@media (max-width: 720px) {
  /* 지역 — 가로 3분할 칩. 부가 설명(sub/boss)은 생략하고 썸네일+이름+난이도만 */
  #map-row { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 5px; padding: 0; }
  .map-card { display: flex; flex-direction: column; padding: 5px 5px 6px; width: auto; }
  .map-card img { width: 100%; height: 30px; object-fit: cover; }
  .map-card .mc-sub, .map-card .mc-boss { display: none; }
  .map-card .mc-name { font-size: 10px; margin-top: 4px; }
  .mc-diff { font-size: 8px; padding: 0 4px; margin-left: 2px; border-width: 1px; }

  /* 기체 — 2열 컴팩트 타일. 밴드 슬림화, 설명 숨김, 스탯 바 압축 */
  #unit-row { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; }
  .unit-card .uc-band { padding: 2px 7px; border-bottom-width: 2px; font-size: 10px; }
  .unit-card .uc-band .tag { font-size: 8px; padding: 0 5px; }
  .unit-card .uc-body { padding: 5px 6px; gap: 6px; }
  .unit-card canvas { width: 34px; height: 40px; border-width: 1.5px; }
  .uc-name { font-size: 11px; }
  .unit-card .uc-pilot { font-size: 8px; }
  .unit-card .uc-weapon { font-size: 8px; margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .unit-card .uc-desc { display: none; } /* 타일 압축 — 특성 설명은 생략 */
  .uc-stats { gap: 1px; margin: 1px 0; }
  .uc-stat { gap: 4px; }
  .uc-stat span { font-size: 6px; width: 18px; line-height: 1; }
  .uc-stat i { height: 4px; }
  .uc-info { gap: 1px; }
  .unit-card .uc-name, .unit-card .uc-pilot, .unit-card .uc-weapon { line-height: 1.25; }
  .unit-card .uc-band, .unit-card .uc-band .tag { line-height: 1.2; }

  /* 패치 보드는 패치노트 터미널 버튼으로 대체 — 모바일 공간 절약 */
  #patch-board { display: none; }

  /* 라벨·입력·터미널 행 간격 압축 */
  .section-label { margin: 8px 0 4px; }
  #callsign { padding: 5px 9px 5px 24px; font-size: 11px; } /* 좌측 ▸ 장식 공간 확보 */
  #title-term { margin-top: 4px; flex-wrap: nowrap; }
  .term-btn { flex: 1 1 auto; font-size: 9px; padding: 7px 1px; letter-spacing: 0; border-top-width: 0; }
  #title-term { flex-wrap: wrap; }
  #title-term .term-btn { flex: 1 1 auto; }
  #title-term #visit-chip {
    flex: 1 0 100%; order: 9; border-width: 1px 0 0; border-color: var(--line2);
    font-size: 8px; padding: 2px 6px; text-align: center; margin-left: 0;
  }
  #copyright { font-size: 8px; margin-top: 2px; line-height: 1.4; }
  #title-inner { padding-bottom: 50px; } /* 스티키 출격 바 높이에 맞춰 축소 */
  #sortie-bar { font-size: 10px; }
}
@media (max-width: 520px) {
  .term-btn { font-size: 8.5px; }
  .unit-card canvas { width: 32px; height: 38px; }
}
/* v0.2.39 — 높이 반응형 간격: 키 큰 모바일은 스텝 라벨 호흡 넉넉히, 작은 화면은 로고 부제 생략 */
@media (max-width: 720px) and (min-height: 740px) {
  .section-label { margin: 12px 0 5px; }
}
@media (max-width: 720px) and (max-height: 700px) {
  #title-logo .sub { display: none; } /* 초소형 높이 — 부제 생략해 본문 공간 확보 */
  .section-label { margin: 6px 0 3px; } /* 낮은 화면은 콤팩트 간격 유지 */
}

/* ==================== v0.2.40 — 사도 도감 + 가로모드 타이틀 ==================== */
/* --- 사도 도감 시트 --- */
.codex-sheet { width: min(94vw, 720px); max-height: 88vh; display: flex; flex-direction: column; }
.codex-sheet h2 { font-size: clamp(17px, 4.5vw, 24px); }
.cdx-tabs { display: flex; gap: 8px; margin-bottom: 10px; }
.cdx-tabs .cartoon-btn { font-size: 12px; padding: 5px 14px; }
#cdx-list, #cdx-achv { overflow-y: auto; min-height: 0; flex: 1; }
.cdx-sec { font-family: 'Galmuri11', sans-serif; font-size: 12px; color: var(--green); letter-spacing: 1px; margin: 10px 0 6px; border-bottom: 1px solid var(--line2); padding-bottom: 3px; }
.cdx-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(148px, 1fr)); gap: 7px; }
.cdx-cell { border: 2px solid var(--line2); background: rgba(10, 14, 6, .6); padding: 8px; text-align: center; }
.cdx-cell.boss { border-color: rgba(255, 100, 80, .4); }
.cdx-cell.unseen { opacity: .45; }
.cdx-cell img { width: 52px; height: 52px; object-fit: contain; image-rendering: pixelated; }
.cdx-glyph { display: inline-block; width: 52px; height: 52px; line-height: 52px; font-size: 26px; color: var(--dim); font-style: normal; }
.cdx-nm { font-family: 'Galmuri11', sans-serif; font-size: 12px; color: #fff; margin-top: 4px; }
.cdx-k { font-family: 'Galmuri9', monospace; font-size: 9px; color: var(--yellow); margin-top: 2px; }
.cdx-fl { font-size: 9px; color: var(--dim); margin-top: 3px; line-height: 1.4; }
.achv-row { display: flex; align-items: center; gap: 10px; padding: 7px 9px; border: 1px solid var(--line2); margin-bottom: 5px; background: rgba(10, 14, 6, .5); }
.achv-row.done { border-color: rgba(255, 226, 60, .5); background: rgba(40, 34, 8, .5); }
.achv-t { flex: 1; min-width: 0; }
.achv-t b { font-family: 'Galmuri11', sans-serif; font-size: 13px; color: #fff; display: block; }
.achv-t span { font-size: 10px; color: var(--dim); }
.achv-p { flex: 0 0 110px; position: relative; height: 14px; background: #090c06; border: 1px solid var(--line2); }
.achv-p i { position: absolute; inset: 0 auto 0 0; background: var(--green); opacity: .8; }
.achv-row.done .achv-p i { background: var(--yellow); }
.achv-p em { position: absolute; inset: 0; font-family: 'Galmuri9', monospace; font-size: 8px; font-style: normal; color: #fff; text-align: center; line-height: 14px; text-shadow: 1px 1px 0 #000; }

/* --- 가로모드 타이틀 (M-05) — 낮은 높이 가로 화면에서 2단 배치 --- */
@media (max-height: 480px) and (orientation: landscape) {
  #title-inner {
    display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 7fr); column-gap: 16px;
    grid-template-areas:
      'st st'
      'hd hd'
      's1 s3'
      'mr ur'
      's2 ur'
      'cr ur'
      'tm tm'
      'cp cp';
    padding: 4px 10px 46px; text-align: left;
  }
  #title-status { grid-area: st; margin-bottom: 2px; }
  #title-head { grid-area: hd; margin-bottom: 0; }
  #title-logo .kr { font-size: clamp(18px, 5.5vh, 26px); -webkit-text-stroke-width: 1px; }
  #title-logo .sub { display: none; }
  #title-stats { display: none; }
  .step-1 { grid-area: s1; } .step-2 { grid-area: s2; } .step-3 { grid-area: s3; }
  #map-row { grid-area: mr; } #callsign-row { grid-area: cr; } #unit-row { grid-area: ur; }
  #title-term { grid-area: tm; } #copyright { grid-area: cp; }
  .section-label { margin: 4px 0 3px; }
  .step-hint { display: none; }
  .map-scroll-hint { display: none; }
  #patch-board { display: none; }
  /* 지역 — 좁은 좌단에 가로 3분할 미니 칩 */
  #map-row { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 4px; }
  .map-card { display: flex; flex-direction: column; padding: 4px; width: auto; }
  .map-card img { width: 100%; height: 26px; object-fit: cover; }
  .map-card .mc-sub, .map-card .mc-boss { display: none; }
  .map-card .mc-name { font-size: 9px; margin-top: 3px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .mc-diff { font-size: 7px; padding: 0 3px; margin-left: 1px; border-width: 1px; }
  /* 기체 — 우단 3열×2행 컴팩트 타일 */
  #unit-row { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 5px; }
  .unit-card .uc-band { padding: 1px 6px; border-bottom-width: 2px; font-size: 9px; }
  .unit-card .uc-band .tag { font-size: 7px; padding: 0 4px; }
  .unit-card .uc-body { padding: 4px 5px; gap: 5px; flex-direction: row; align-items: flex-start; text-align: left; }
  .unit-card canvas { width: 28px; height: 33px; border-width: 1.5px; }
  .uc-name { font-size: 10px; text-align: left; }
  .unit-card .uc-pilot { font-size: 7px; text-align: left; }
  .unit-card .uc-weapon { font-size: 7px; margin-top: 1px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; text-align: left; }
  .unit-card .uc-desc { display: none; }
  .uc-stats { gap: 1px; margin: 1px 0; }
  .uc-stat { gap: 3px; }
  .uc-stat span { font-size: 6px; width: 15px; line-height: 1; }
  .uc-stat i { height: 3px; }
  .unit-card .uc-name, .unit-card .uc-pilot, .unit-card .uc-weapon { line-height: 1.2; }
  #callsign-row { margin: 0; }
  #callsign { padding: 4px 8px 4px 22px; font-size: 10px; }
  #callsign-row .cs-hint, #callsign-row .tag { display: none; }
  #title-term { margin-top: 4px; flex-wrap: nowrap; }
  .term-btn { font-size: 9px; padding: 5px 1px; letter-spacing: 0; }
  #title-term #visit-chip { display: none; }
  #copyright { font-size: 7px; margin-top: 2px; }
  .map-card.sel::after { display: none; } /* 미니 칩에서는 배지가 이름을 가림 — 녹색 테두리로 선택 표기 */
  #sortie-bar { padding: 6px 10px calc(6px + env(safe-area-inset-bottom, 0px)); font-size: 10px; }
}
