/* 헬다이버즈 2 섹션 공통 스타일 (허브, 티어 메이커)
   레이아웃: 슈퍼 디스트로이어 함선 터미널 느낌. 검정 바탕 + 노랑 강조 + 경고 사선 + 모서리를 깎은 패널 */
:root {
  --hd-bg: #0a0b0d;
  --hd-panel: #131519;
  --hd-panel-2: #1b1e23;
  --hd-line: #30343c;
  --hd-line-2: #4a4f59;
  --hd-text: #e9eaec;
  --hd-dim: #9aa0aa;
  --hd-yellow: #ffe711;
  --hd-yellow-ink: #141200;
  --hd-red: #ff4b3e;
  --hd-f-display: "Black Han Sans", "Chakra Petch", "IBM Plex Sans KR", sans-serif;
  --hd-f-ui: "Chakra Petch", "IBM Plex Sans KR", system-ui, sans-serif;
  --hd-f-body: "IBM Plex Sans KR", system-ui, -apple-system, "Malgun Gothic", sans-serif;
  --hd-cut: 12px;
  /* 티어 메이커 타일 배율 (보기 > 크기). 1.5 가 스프라이트 원본 해상도라 그 이상은 흐려진다 */
  --s: 1;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { min-height: 100%; }
body { margin: 0; background: var(--hd-bg); color: var(--hd-text); font-family: var(--hd-f-body); font-size: 15px; line-height: 1.55; word-break: keep-all; -webkit-font-smoothing: antialiased; }
/* 화면 전체에 아주 옅은 주사선 */
body::before { content: ""; position: fixed; inset: 0; z-index: 100; pointer-events: none; background: repeating-linear-gradient(0deg, rgba(255, 255, 255, .018) 0 1px, transparent 1px 3px); }
a { color: var(--hd-yellow); }
button, input, select { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--hd-yellow); outline-offset: 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.hd-wrap { width: min(1320px, 100%); margin-inline: auto; padding-inline: 16px; }
.hazard { height: 8px; background: repeating-linear-gradient(-45deg, var(--hd-yellow) 0 10px, #0d0d0d 10px 20px); }
.cut { clip-path: polygon(var(--hd-cut) 0, 100% 0, 100% calc(100% - var(--hd-cut)), calc(100% - var(--hd-cut)) 100%, 0 100%, 0 var(--hd-cut)); }
.eyebrow { margin: 0; font: 600 12px/1.2 var(--hd-f-ui); letter-spacing: .18em; text-transform: uppercase; color: var(--hd-yellow); }

/* 상단 바 */
.hd-top { border-bottom: 1px solid var(--hd-line); background: #08090a; }
.hd-top .hd-wrap { display: flex; align-items: center; gap: 14px; min-height: 56px; }
.hd-back { display: inline-flex; align-items: center; gap: 8px; padding: 6px 10px; border: 1px solid var(--hd-line-2); color: var(--hd-text); text-decoration: none; font: 600 13px/1 var(--hd-f-ui); letter-spacing: .04em; }
.hd-back:hover { border-color: var(--hd-yellow); color: var(--hd-yellow); }
.hd-lang { padding: 6px 10px; border: 1px solid var(--hd-line-2); background: transparent; color: var(--hd-text); font: 600 13px/1 var(--hd-f-ui); letter-spacing: .04em; cursor: pointer; }
.hd-lang:hover { border-color: var(--hd-yellow); color: var(--hd-yellow); }
/* 영어 화면: 한국어 글자를 영어로 바꿀 때까지 잠깐 숨긴다 (js/i18n.js, HTML 의 언어 부트 스크립트) */
.i18n-wait body { visibility: hidden; }
.hd-brand { display: grid; gap: 2px; margin-right: auto; }
.hd-brand b { font: 400 18px/1.1 var(--hd-f-display); letter-spacing: .02em; }

/* 버튼 */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 38px; padding: 8px 16px; border: 0; background: var(--hd-yellow); color: var(--hd-yellow-ink); font: 700 14px/1 var(--hd-f-ui); letter-spacing: .03em; cursor: pointer; clip-path: polygon(8px 0, 100% 0, 100% calc(100% - 8px), calc(100% - 8px) 100%, 0 100%, 0 8px); }
.btn:hover { filter: brightness(1.08); }
.btn:active { transform: translateY(1px); }
.btn.ghost { background: transparent; color: var(--hd-text); box-shadow: inset 0 0 0 1px var(--hd-line-2); }
.btn.ghost:hover { color: var(--hd-yellow); box-shadow: inset 0 0 0 1px var(--hd-yellow); }
.btn.danger { background: transparent; color: var(--hd-red); box-shadow: inset 0 0 0 1px rgba(255, 75, 62, .6); }
.btn.danger[data-armed="true"] { background: var(--hd-red); color: #1a0402; }

/* 알림 */
.hd-toast { position: fixed; z-index: 90; left: 50%; bottom: calc(env(safe-area-inset-bottom, 0px) + 22px); transform: translateX(-50%); padding: 10px 16px; background: var(--hd-yellow); color: var(--hd-yellow-ink); font: 700 14px/1.3 var(--hd-f-ui); clip-path: polygon(8px 0, 100% 0, 100% calc(100% - 8px), calc(100% - 8px) 100%, 0 100%, 0 8px); }
.hd-toast[hidden] { display: none; }


/* ===================== 허브 (함선 터미널) ===================== */
.hub { padding-block: 40px 24px; display: grid; gap: 28px; }
.hub-hero { display: grid; gap: 10px; }
.hub-hero h1 { margin: 0; font: 400 clamp(34px, 6vw, 60px)/1.05 var(--hd-f-display); letter-spacing: .01em; text-wrap: balance; }
.hub-hero p { margin: 0; color: var(--hd-dim); max-width: 60ch; }
.hub-ship { display: inline-flex; gap: 10px; align-items: center; font: 600 13px/1 var(--hd-f-ui); letter-spacing: .12em; color: var(--hd-dim); }
.hub-ship i { width: 8px; height: 8px; background: #3fdc6b; box-shadow: 0 0 10px #3fdc6b; animation: hd-blink 1.6s steps(2, start) infinite; }
.hub-menu { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 16px; }
.module { position: relative; display: grid; gap: 10px; padding: 22px 22px 20px; min-height: 190px; background: var(--hd-panel); border: 1px solid var(--hd-line); text-decoration: none; color: var(--hd-text); overflow: hidden; }
.module::after { content: ""; position: absolute; right: 0; bottom: 0; width: 46px; height: 46px; background: linear-gradient(135deg, transparent 50%, var(--hd-line) 50%); }
a.module:hover { border-color: var(--hd-yellow); background: var(--hd-panel-2); }
a.module:hover::after { background: linear-gradient(135deg, transparent 50%, var(--hd-yellow) 50%); }
.module .num { font: 700 13px/1 var(--hd-f-ui); color: var(--hd-yellow); letter-spacing: .12em; }
.module h2 { margin: 0; font: 400 28px/1.15 var(--hd-f-display); }
.module p { margin: 0; color: var(--hd-dim); font-size: 14px; }
.module .go { margin-top: auto; font: 700 13px/1 var(--hd-f-ui); letter-spacing: .1em; color: var(--hd-yellow); }
.module.locked { opacity: .55; }
.module.locked .go { color: var(--hd-dim); }
/* 강하 착지: 허브에 들어올 때 화면이 한 번 흔들림 */
.landing .hub { animation: hd-land .55s cubic-bezier(.2, 1.4, .4, 1) both; }

/* ===================== 티어 메이커 ===================== */
.tm { padding-block: 20px 48px; display: grid; gap: 16px; }
/* 화면 타일 크기 = 분류별 기본 크기(catalog.js 가 넣는 --tile-*) × 배율 --s.
   AI-NOTE: 크기를 키워도 티어 라벨(S, A, B...)은 그대로 둔다 (유저 요청: 방송에서 중요한 건 아이콘, 라벨은 작아도 알아봄) */
#app { --tw: calc(var(--tile-w) * var(--s)); --th: calc(var(--tile-h) * var(--s)); --sw: calc(var(--sprite-w) * var(--s)); --sh: calc(var(--sprite-h) * var(--s)); }
/* 크게 볼 때만 본문을 넓힌다 (작게 볼 때는 기본 폭을 유지해서 한 줄에 더 많이 들어가게) */
.tm.hd-wrap { width: min(max(1320px, calc(1320px * var(--s))), 100%); }
.tm-head { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 12px 16px; }
.tm-title { flex: 1 1 320px; min-width: 0; display: grid; gap: 6px; }
.tm-title input { width: 100%; padding: 6px 0 8px; border: 0; border-bottom: 2px solid var(--hd-line-2); background: transparent; font: 400 clamp(24px, 3.4vw, 34px)/1.15 var(--hd-f-display); color: var(--hd-text); }
.tm-title input:focus { outline: none; border-bottom-color: var(--hd-yellow); }
.tm-actions { display: flex; flex-wrap: wrap; gap: 8px; }

.tabs { display: flex; gap: 2px; overflow-x: auto; scrollbar-width: none; border-bottom: 1px solid var(--hd-line); }
.tab { flex: none; padding: 11px 16px 10px; border: 0; background: transparent; color: var(--hd-dim); font: 600 14px/1 var(--hd-f-ui); letter-spacing: .02em; cursor: pointer; border-bottom: 3px solid transparent; white-space: nowrap; }
.tab:hover { color: var(--hd-text); }
.tab[aria-selected="true"] { color: var(--hd-yellow); border-bottom-color: var(--hd-yellow); background: linear-gradient(0deg, rgba(255, 231, 17, .08), transparent); }
.tab small { margin-left: 6px; color: var(--hd-dim); font-weight: 400; }

/* 보기 설정 줄: 크기, 이름 표시, 방송용 보기 */
.tm-view { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; }
.seg { display: inline-flex; border: 1px solid var(--hd-line-2); }
.seg button { min-height: 32px; padding: 4px 12px; border: 0; background: transparent; color: var(--hd-dim); font: 600 13px/1 var(--hd-f-ui); cursor: pointer; }
.seg button + button { border-left: 1px solid var(--hd-line-2); }
.seg button[aria-pressed="true"] { background: var(--hd-yellow); color: var(--hd-yellow-ink); }

/* 방송용 보기: 머리말·정보 패널을 숨기고 티어표를 넓게 (좁은 화면에서는 정보 시트가 배치 수단이라 남긴다) */
body.stream .hd-top, body.stream .kbd-hint { display: none; }
body.stream .tm { padding-top: 12px; }
@media (min-width: 961px) {
  body.stream .info { display: none; }
  body.stream .tm-body { grid-template-columns: minmax(0, 1fr); }
}

.tm-body { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 16px; align-items: start; }

/* 티어 줄 */
.board { display: grid; gap: 4px; }
.tier { display: grid; grid-template-columns: 92px minmax(0, 1fr); min-height: calc(var(--th) + 16px); background: var(--hd-panel); border: 1px solid var(--hd-line); }
.tier-label { position: relative; display: grid; place-items: center; padding: 8px 4px; border: 0; background: var(--tier-color); color: #0d0d0d; font: 400 26px/1.05 var(--hd-f-display); text-align: center; cursor: pointer; overflow-wrap: anywhere; }
.tier-label:hover::after { content: "편집"; position: absolute; right: 4px; bottom: 3px; font: 700 10px/1 var(--hd-f-ui); letter-spacing: .08em; color: rgba(0, 0, 0, .55); }
:root[lang="en"] .tier-label:hover::after { content: "Edit"; }
.drop { display: flex; flex-wrap: wrap; align-content: flex-start; gap: calc(6px * var(--s)); padding: 8px; min-width: 0; }
.drop.over { background: rgba(255, 231, 17, .06); box-shadow: inset 0 0 0 1px rgba(255, 231, 17, .5); }
.drop .empty { align-self: center; color: #5b616c; font-size: 13px; padding-left: 4px; }

/* 아이템 타일 (스프라이트 한 칸을 잘라 보여 줌) */
.tile { position: relative; flex: none; display: grid; justify-items: center; gap: 3px; width: var(--tw); padding: 0; border: 0; background: none; cursor: grab; touch-action: manipulation; -webkit-tap-highlight-color: transparent; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
/* 터치로 꾹 누르는 동안 살짝 눌리는 표시. 전환 시간은 js/hd2/drag.js 의 LONG_PRESS_MS 와 같게 (다 눌리면 집어 든다) */
.tile.pressing .tile-img { transform: scale(.9); transition: transform .32s ease-out; }
.tile-img { display: block; width: var(--tw); height: var(--th); background-color: #0e1013; background-image: var(--sprite); background-size: var(--sw) var(--sh); background-position: calc(var(--x) * var(--s)) calc(var(--y) * var(--s)); background-repeat: no-repeat; box-shadow: inset 0 0 0 1px var(--hd-line); }
.tile-name { width: 100%; font-size: calc(11px * var(--s)); line-height: 1.25; color: var(--hd-dim); text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hide-names .tile-name { display: none; }
.tile:hover .tile-img { box-shadow: inset 0 0 0 1px var(--hd-yellow); }
.tile[aria-pressed="true"] .tile-img { box-shadow: inset 0 0 0 2px var(--hd-yellow), 0 0 14px rgba(255, 231, 17, .35); }
.tile[aria-pressed="true"] .tile-name { color: var(--hd-yellow); }
.tile.dragging { opacity: .25; }
.drag-ghost { position: fixed; z-index: 80; left: 0; top: 0; pointer-events: none; transform: translate(-50%, -50%) rotate(-3deg) scale(1.06); filter: drop-shadow(0 8px 16px rgba(0, 0, 0, .6)); }
.drag-ghost .tile-img { box-shadow: inset 0 0 0 2px var(--hd-yellow); }
.drop-mark { flex: none; width: 3px; align-self: stretch; min-height: var(--th); background: var(--hd-yellow); box-shadow: 0 0 8px var(--hd-yellow); }

/* 미배치 + 필터 */
.pool { display: grid; gap: 10px; padding: 14px; background: var(--hd-panel); border: 1px solid var(--hd-line); }
.pool-head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 10px; }
.pool-head h2 { margin: 0 auto 0 0; font: 400 20px/1 var(--hd-f-display); }
.pool-head h2 small { margin-left: 8px; font: 600 13px/1 var(--hd-f-ui); color: var(--hd-dim); }
.field { display: inline-flex; align-items: center; gap: 6px; padding: 0 10px; min-height: 36px; background: #0d0f12; border: 1px solid var(--hd-line-2); }
.field:focus-within { border-color: var(--hd-yellow); }
.field input, .field select { min-width: 0; border: 0; background: transparent; padding: 7px 0; outline: none; }
.field select option { background: #15171b; }
.field input { width: 150px; }
.toggle { display: inline-flex; align-items: center; gap: 6px; font: 600 13px/1 var(--hd-f-ui); color: var(--hd-dim); cursor: pointer; }
.toggle input { accent-color: var(--hd-yellow); }
.pool .drop { padding: 4px 0 0; min-height: calc(var(--th) + 20px); }

/* 정보 패널 (게임 무기고 옆 패널 느낌) */
.info { position: sticky; top: 12px; display: grid; gap: 12px; padding: 16px; background: var(--hd-panel); border: 1px solid var(--hd-line); }
.info-empty { color: var(--hd-dim); font-size: 14px; }
.info-art { height: 128px; display: grid; place-items: center; background: #0d0f12; box-shadow: inset 0 0 0 1px var(--hd-line); }
.info-art span { display: block; background-image: var(--sprite); background-repeat: no-repeat; }
.info h3 { margin: 0; font: 400 24px/1.15 var(--hd-f-display); }
.info .en { margin: 2px 0 0; font: 600 13px/1.3 var(--hd-f-ui); color: var(--hd-dim); letter-spacing: .04em; }
.info dl { margin: 0; display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 6px 12px; font-size: 13.5px; }
.info dt { color: var(--hd-dim); font: 600 12px/1.6 var(--hd-f-ui); letter-spacing: .06em; }
.info dd { margin: 0; overflow-wrap: anywhere; }
.info .note { margin: 0; padding: 10px 12px; background: #0d0f12; border-left: 3px solid var(--hd-yellow); font-size: 14px; }
.arrows { display: flex; flex-wrap: wrap; gap: 4px; }
.arrows span { display: grid; place-items: center; width: 26px; height: 26px; background: var(--hd-yellow); color: var(--hd-yellow-ink); font: 700 16px/1 var(--hd-f-ui); }
.specs { display: grid; gap: 8px; padding-top: 10px; border-top: 1px solid var(--hd-line); }
.traits { display: flex; flex-wrap: wrap; gap: 4px; }
.traits span { padding: 3px 8px; border: 1px solid var(--hd-line-2); color: #cfd2d7; font: 600 12px/1.2 var(--hd-f-ui); }
.spec-date { margin: 0; color: #6b717c; font-size: 11.5px; }
.place { display: grid; gap: 8px; }
.place-row { display: flex; flex-wrap: wrap; gap: 6px; }
.place-row button { min-width: 42px; min-height: 36px; padding: 6px 10px; border: 0; background: var(--tier-color); color: #0d0d0d; font: 400 16px/1 var(--hd-f-display); cursor: pointer; }
.place-row button.out { background: transparent; color: var(--hd-text); box-shadow: inset 0 0 0 1px var(--hd-line-2); font: 600 13px/1 var(--hd-f-ui); }
.info-close { display: none; }
.kbd-hint { margin: 0; color: #6b717c; font-size: 12px; }

/* 티어 편집 팝업 */
.editor { position: fixed; z-index: 85; width: min(320px, calc(100vw - 32px)); display: grid; gap: 12px; padding: 16px; background: var(--hd-panel-2); border: 1px solid var(--hd-yellow); box-shadow: 0 18px 40px rgba(0, 0, 0, .6); }
.editor[hidden] { display: none; }
.editor h3 { margin: 0; font: 400 18px/1 var(--hd-f-display); }
.editor .field { width: 100%; }
.editor .field input { width: 100%; }
.swatches { display: flex; flex-wrap: wrap; gap: 6px; }
.swatches button { width: 30px; height: 30px; border: 0; background: var(--c); cursor: pointer; }
.swatches button[aria-pressed="true"] { outline: 2px solid #fff; outline-offset: 2px; }
.editor-row { display: flex; flex-wrap: wrap; gap: 6px; }
.editor-row .btn { min-height: 34px; padding: 6px 12px; font-size: 13px; }

.tm-loading { padding: 60px 0; text-align: center; color: var(--hd-dim); font: 600 14px/1.4 var(--hd-f-ui); letter-spacing: .14em; }


@keyframes hd-blink { to { visibility: hidden; } }
@keyframes hd-land { 0% { transform: translateY(-28px); opacity: 0; } 60% { transform: translateY(4px); opacity: 1; } 80% { transform: translateY(-2px); } }

/* 좁은 화면: 정보 패널을 아래에서 올라오는 시트로 */
@media (max-width: 960px) {
  .tm-body { grid-template-columns: minmax(0, 1fr); }
  .info { position: fixed; z-index: 70; left: 0; right: 0; bottom: 0; top: auto; max-height: 62vh; overflow-y: auto; padding-bottom: calc(16px + env(safe-area-inset-bottom, 0px)); border: 0; border-top: 2px solid var(--hd-yellow); transform: translateY(105%); transition: transform .22s ease-out; }
  .info.open { transform: none; }
  .info-art { height: 96px; }
  .info-close { display: inline-flex; justify-self: end; }
  .kbd-hint { display: none; }
}
@media (max-width: 560px) {
  .tier { grid-template-columns: 62px minmax(0, 1fr); }
  .tier-label { font-size: 20px; }
  .field input { width: 110px; }
  .tm-actions .btn { flex: 1 1 auto; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
