/* ============ 물류 IT 아카이브 — 입체 포트폴리오 스타일 (차콜 & 골드 에디션) ============ */
:root {
  --ink: #101116;
  --panel: #191b22;
  --panel-2: #22252f;
  --panel-edge: #3a3e4d;
  --gold: #d4b36a;
  --gold-soft: #e6d3a3;
  --steel: #93a7c4;
  --mint: #9dc4a8;
  --text: #f2f3f7;
  --text-dim: #a8adbd;
  --font-pixel: 'DungGeunMo', 'Apple SD Gothic Neo', 'Malgun Gothic', sans-serif;
  --font-body: 'Noto Sans KR', -apple-system, 'Apple SD Gothic Neo', 'Malgun Gothic', sans-serif;
  --font-read: 'Noto Sans KR', -apple-system, BlinkMacSystemFont, 'Apple SD Gothic Neo', 'Pretendard', 'Malgun Gothic', sans-serif;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html, body {
  width: 100%; height: 100%;
  height: 100dvh;
  overflow: hidden;
  background: var(--ink);
  font-family: var(--font-body);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
  touch-action: none;
  overscroll-behavior: none;
}

#game-canvas {
  position: fixed; inset: 0; width: 100%; height: 100%; display: block;
}

.hidden { display: none !important; }

/* ---------- 에러 오버레이 ---------- */
#error-overlay {
  position: fixed; left: 12px; bottom: 12px; z-index: 999;
  max-width: 70vw; max-height: 40vh; overflow: auto;
  background: #5b1a1a; color: #ffd7d7; border: 2px solid #ff6b6b;
  padding: 10px 14px; font-size: 12px; white-space: pre-wrap; border-radius: 6px;
}

/* ---------- 타이틀 화면 ---------- */
.overlay {
  position: fixed; inset: 0; z-index: 60;
  display: flex; align-items: center; justify-content: center;
  background: radial-gradient(ellipse at 50% 28%, rgba(28,30,40,.55), rgba(10,11,16,.9));
  backdrop-filter: blur(3px);
  padding: 20px;
  overflow: hidden;
}

/* 둥둥 떠다니는 장식 이모지 */
.title-deco { position: absolute; inset: 0; pointer-events: none; }
.title-deco span {
  position: absolute;
  font-size: clamp(24px, 4vw, 34px);
  opacity: .45;
  filter: grayscale(.35) drop-shadow(0 4px 10px rgba(0,0,0,.4));
  animation: deco-float 5s ease-in-out infinite alternate;
}
.title-deco span:nth-child(1) { left: 9%;  top: 16%; animation-duration: 4.4s; }
.title-deco span:nth-child(2) { right: 11%; top: 22%; animation-duration: 5.6s; animation-delay: .6s; }
.title-deco span:nth-child(3) { left: 16%; bottom: 18%; animation-duration: 5s;   animation-delay: 1.2s; }
.title-deco span:nth-child(4) { right: 18%; bottom: 24%; animation-duration: 4.2s; animation-delay: .3s; }
.title-deco span:nth-child(5) { left: 42%; top: 9%;  animation-duration: 6s;   animation-delay: 1.8s; }
.title-deco span:nth-child(6) { right: 40%; bottom: 10%; animation-duration: 5.2s; animation-delay: 1s; }
@keyframes deco-float {
  from { transform: translateY(-8px) rotate(-4deg); }
  to   { transform: translateY(10px) rotate(5deg); }
}

.title-card {
  position: relative;
  max-width: 640px; width: 100%;
  background: linear-gradient(180deg, var(--panel-2), var(--panel));
  border: 1px solid var(--panel-edge);
  border-radius: 14px;
  box-shadow: 0 0 0 1px #0b0c10, 0 0 44px rgba(212,179,106,.08), 0 24px 60px rgba(0,0,0,.65), inset 0 1px 0 rgba(255,255,255,.05);
  padding: 44px 38px 32px;
  text-align: center;
  animation: card-in .45s cubic-bezier(.2, 1.2, .4, 1);
}
@keyframes card-in {
  from { transform: scale(.92) translateY(14px); opacity: 0; }
  to   { transform: scale(1) translateY(0); opacity: 1; }
}
.title-badge {
  display: inline-block;
  font-size: 11.5px; letter-spacing: .42em; color: var(--steel);
  border: 1px solid rgba(147,167,196,.4);
  padding: 6px 14px 5px; border-radius: 99px; margin-bottom: 20px;
  background: rgba(147,167,196,.06);
}
.title-main {
  font-family: var(--font-read);
  font-weight: 700;
  font-size: clamp(28px, 5vw, 40px);
  color: var(--gold);
  letter-spacing: .02em; margin-bottom: 12px;
}
.title-sub { font-family: var(--font-read); font-size: 15.5px; color: var(--text); letter-spacing: .02em; }
.title-sub-en { color: var(--text-dim); font-size: 12.5px; letter-spacing: .14em; }
.title-rule {
  width: 64px; height: 1px; margin: 18px auto 16px;
  background: linear-gradient(90deg, transparent, var(--gold), transparent);
}
.title-tag { margin: 0 0 26px; color: var(--text-dim); font-family: var(--font-read); font-size: 14px; line-height: 1.7; }

.btn {
  font-family: var(--font-read);
  cursor: pointer; border: 0;
  border-radius: 10px;
  transition: transform .1s ease, box-shadow .1s ease, filter .15s;
}
.btn:active { transform: translateY(2px); }
.btn-primary {
  font-size: 17px; font-weight: 600;
  letter-spacing: .04em;
  color: #17130a;
  background: linear-gradient(180deg, #e3c887, var(--gold) 55%, #b99751);
  padding: 14px 38px 12px;
  box-shadow: 0 5px 0 #8a7038, 0 12px 24px rgba(0,0,0,.5);
}
.btn-primary:hover { filter: brightness(1.05); }
.btn-primary:active { box-shadow: 0 2px 0 #8a7038, 0 6px 14px rgba(0,0,0,.4); }

.title-help {
  margin-top: 28px; padding-top: 18px;
  border-top: 1px solid rgba(255,255,255,.08);
  display: flex; flex-wrap: wrap; gap: 10px 24px; justify-content: center;
  color: var(--text-dim); font-family: var(--font-read); font-size: 12.5px;
}
.title-help b { color: var(--steel); margin-right: 6px; font-weight: 600; }

/* ---------- HUD ---------- */
#hud {
  position: fixed; top: 0; left: 0; right: 0; z-index: 40;
  display: flex; align-items: center; gap: 12px;
  padding: 12px 14px;
  pointer-events: none;
}
.hud-left { pointer-events: auto; }
.hud-name {
  font-family: var(--font-read);
  font-size: 15px; font-weight: 600; color: #fff;
  background: rgba(20,22,29,.88);
  border: 1px solid var(--panel-edge);
  padding: 7px 14px; border-radius: 10px;
  box-shadow: 0 4px 14px rgba(0,0,0,.35);
  display: flex; align-items: center; gap: 8px;
}
.hud-avatar { font-size: 14px; }
.hud-name .hud-title { color: var(--gold); font-size: 12px; font-weight: 500; margin-left: 2px; }

.hud-nav {
  pointer-events: auto;
  margin-left: auto; margin-right: auto;
  display: flex; gap: 7px; flex-wrap: wrap; justify-content: center;
}
.nav-btn {
  font-family: var(--font-read);
  font-size: 13px; font-weight: 500; color: var(--text);
  background: rgba(20,22,29,.88);
  border: 1px solid var(--panel-edge);
  padding: 7px 12px 6px; border-radius: 9px;
  cursor: pointer;
  transition: transform .08s, border-color .15s, color .15s;
}
.nav-btn:hover { transform: translateY(-1px); border-color: var(--gold); color: var(--gold-soft); }
.nav-btn:active { transform: translateY(1px); }

.hud-right { pointer-events: auto; display: flex; gap: 6px; }
.icon-btn {
  width: 38px; height: 38px;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 16px; color: var(--text); text-decoration: none;
  background: rgba(20,22,29,.88);
  border: 1px solid var(--panel-edge); border-radius: 9px;
  cursor: pointer;
  transition: border-color .15s, transform .08s;
}
.icon-btn:hover { border-color: var(--gold); transform: translateY(-1px); }

@media (max-width: 900px) {
  .hud-nav { order: 3; width: 100%; margin: 0; }
  #hud { flex-wrap: wrap; padding: 8px 10px; gap: 8px; }
}

/* ---------- 상호작용 프롬프트 ---------- */
#prompt {
  position: fixed; z-index: 30;
  transform: translate(-50%, -100%);
  display: flex; align-items: center; gap: 8px;
  background: rgba(20,22,29,.94);
  border: 1px solid var(--gold);
  border-radius: 10px;
  padding: 6px 13px 5px 7px;
  font-family: var(--font-read);
  font-size: 13.5px; font-weight: 500; color: #fff;
  pointer-events: none;
  white-space: nowrap;
  box-shadow: 0 6px 16px rgba(0,0,0,.4);
  animation: prompt-bob 1.4s ease-in-out infinite;
}
@keyframes prompt-bob {
  0%,100% { transform: translate(-50%, -100%) scale(1); }
  50% { transform: translate(-50%, calc(-100% - 6px)) scale(1.02); }
}
.prompt-key {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 22px; height: 22px; padding: 0 4px 0 1px;
  background: var(--gold); color: #17130a;
  border-radius: 5px; font-size: 12.5px; font-weight: 700;
  box-shadow: 0 2px 0 #8a7038;
}
.prompt-label { color: var(--gold-soft); }

/* ---------- 하단 힌트 ---------- */
#hint {
  position: fixed; bottom: 14px; left: 50%; transform: translateX(-50%);
  z-index: 30;
  font-family: var(--font-read);
  font-size: 12.5px; color: var(--text-dim);
  background: rgba(20,22,29,.78);
  border: 1px solid rgba(255,255,255,.1);
  padding: 8px 16px 7px; border-radius: 99px;
  pointer-events: none; white-space: nowrap;
}
#hint b { color: var(--gold); font-weight: 600; }
@media (max-width: 720px) { #hint { display: none; } }

/* ---------- 모바일 컨트롤 ---------- */
#touch-ui { position: fixed; inset: 0; z-index: 35; pointer-events: none; }
#joystick {
  position: absolute; left: 26px; bottom: 30px;
  width: 118px; height: 118px; border-radius: 50%;
  background: rgba(25,27,34,.4);
  border: 2px solid rgba(212,179,106,.4);
  pointer-events: auto; touch-action: none;
}
#joystick-knob {
  position: absolute; left: 50%; top: 50%;
  width: 52px; height: 52px; border-radius: 50%;
  transform: translate(-50%, -50%);
  background: radial-gradient(circle at 35% 30%, #e6d3a3, var(--gold) 65%, #b99751);
  border: 3px solid #fff2;
  box-shadow: 0 4px 10px rgba(0,0,0,.35);
}
#btn-action {
  position: absolute; right: 30px; bottom: 46px;
  width: 76px; height: 76px; border-radius: 50%;
  font-family: var(--font-read); font-size: 24px; font-weight: 700; color: #17130a;
  background: radial-gradient(circle at 35% 30%, #e3c887, var(--gold) 60%, #b99751);
  border: 3px solid #fff2;
  box-shadow: 0 8px 18px rgba(0,0,0,.4);
  pointer-events: auto;
}
#btn-action:active { transform: scale(.94); }

/* ---------- 대화상자 ---------- */
#dialog-backdrop {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(8,9,13,.6);
  backdrop-filter: blur(2px);
}
#dialog {
  position: fixed; z-index: 51;
  left: 50%; top: 50%;
  transform: translate(-50%, -50%);
  width: min(720px, calc(100vw - 28px));
  max-height: min(82vh, 760px);
  display: flex; flex-direction: column;
  background: linear-gradient(180deg, #242732, var(--panel) 22%);
  border: 1px solid var(--panel-edge);
  border-radius: 14px;
  box-shadow: 0 0 0 1px #0b0c10, 0 0 40px rgba(212,179,106,.06), 0 30px 80px rgba(0,0,0,.7), inset 0 1px 0 rgba(255,255,255,.05);
  overflow: hidden;
  animation: dialog-pop .22s cubic-bezier(.2, 1.4, .4, 1);
}
@keyframes dialog-pop {
  from { transform: translate(-50%, -46%) scale(.93); opacity: 0; }
  to   { transform: translate(-50%, -50%) scale(1); opacity: 1; }
}
.dialog-head {
  display: flex; align-items: center; gap: 14px;
  padding: 16px 18px 14px 20px;
  border-bottom: 1px solid rgba(255,255,255,.09);
  background: rgba(13,14,19,.5);
}
.dialog-eyebrow {
  font-family: var(--font-read);
  font-size: 10.5px; letter-spacing: .3em; color: var(--steel);
  border: 1px solid rgba(147,167,196,.4);
  background: rgba(147,167,196,.07);
  padding: 4px 10px 3px; border-radius: 99px; white-space: nowrap;
}
#dialog-title {
  font-family: var(--font-read);
  font-weight: 700;
  font-size: clamp(18px, 3.2vw, 22px);
  color: var(--gold); letter-spacing: -0.01em;
  flex: 1; min-width: 0;
}
.dialog-close {
  width: 34px; height: 34px; flex: none;
  border-radius: 9px; border: 1px solid var(--panel-edge);
  background: rgba(255,255,255,.05); color: var(--text);
  font-size: 14px; cursor: pointer;
  transition: transform .1s, border-color .15s, color .15s;
}
.dialog-close:hover { border-color: var(--gold); color: var(--gold); transform: rotate(90deg); }

.dialog-body {
  padding: 18px 22px 24px;
  overflow-y: auto;
  font-family: var(--font-read);
  font-size: 15.5px;
  line-height: 1.85;
  letter-spacing: -0.01em;
  color: #eceef4;
  scrollbar-width: thin; scrollbar-color: #6b6f80 transparent;
}
.dialog-body::-webkit-scrollbar { width: 10px; }
.dialog-body::-webkit-scrollbar-thumb { background: #6b6f80; border-radius: 6px; border: 2px solid transparent; background-clip: content-box; }
.dialog-foot {
  padding: 9px 18px;
  border-top: 1px solid rgba(255,255,255,.07);
  background: rgba(13,14,19,.5);
}
.dialog-foot-hint { font-family: var(--font-read); font-size: 11px; color: var(--text-dim); }

/* 대화상자 내부 — 시맨틱 구조(section/h3/article/ol) */
.dlg-lead { color: var(--text-dim); margin-bottom: 18px; font-size: 15.5px; }
.dlg-lead strong { color: var(--gold-soft); font-weight: 600; }

.role-chips { display: flex; gap: 6px; flex-wrap: wrap; margin: 0 0 20px; padding: 0; list-style: none; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; margin: 10px 0 0; padding: 0; list-style: none; }
.chip {
  font-size: 12.5px; font-weight: 500; padding: 3px 11px 4px; border-radius: 99px;
  background: rgba(147,167,196,.1); color: var(--steel);
  border: 1px solid rgba(147,167,196,.35);
}
.chip.gold { background: rgba(212,179,106,.1); color: var(--gold); border-color: rgba(212,179,106,.4); }
.chip.pink { background: rgba(212,179,106,.1); color: var(--gold); border-color: rgba(212,179,106,.4); }
.chip.grey { background: rgba(255,255,255,.05); color: var(--text-dim); border-color: rgba(255,255,255,.12); }

section.sec { margin-top: 24px; }
section.sec:first-of-type { margin-top: 0; }
section.sec > h3 {
  font-size: 13px; font-weight: 700; color: var(--gold);
  letter-spacing: .14em; margin: 0 0 12px;
  display: flex; align-items: center; gap: 10px;
}
section.sec > h3::after { content: ''; flex: 1; height: 1px; background: linear-gradient(90deg, rgba(212,179,106,.35), transparent); }
.sec-desc { margin: -4px 0 12px; color: var(--text-dim); font-size: 13.5px; }

article.card {
  background: rgba(13,14,19,.55);
  border: 1px solid rgba(255,255,255,.07);
  border-left: 3px solid var(--gold);
  border-radius: 10px;
  padding: 13px 16px 12px;
  margin-bottom: 10px;
}
article.card.blue { border-left-color: var(--steel); }
article.card.mint { border-left-color: var(--mint); }
article.card h4 { font-weight: 700; font-size: 15.5px; color: #fff; margin: 0 0 4px; }
article.card .meta { font-size: 13px; color: var(--text-dim); margin: 0 0 8px; }
article.card .meta em { font-style: normal; color: var(--steel); font-weight: 600; }
article.card p { font-size: 14.5px; color: #d7dae3; line-height: 1.75; margin: 0; }
article.card p + p { margin-top: 6px; }
article.card em.k { font-style: normal; color: var(--steel); font-weight: 700; margin-right: 2px; }

ol.plist { list-style: none; margin: 0; padding: 0; }
ol.plist > li {
  display: grid;
  grid-template-columns: 122px 1fr auto;
  gap: 2px 12px;
  padding: 10px 4px 9px;
  border-bottom: 1px solid rgba(255,255,255,.07);
  align-items: baseline;
}
ol.plist > li:last-child { border-bottom: 0; }
ol.plist .period { color: var(--steel); font-size: 13px; font-weight: 600; white-space: nowrap; }
ol.plist .pbody { min-width: 0; }
ol.plist .pbody strong { display: block; color: var(--text); font-weight: 500; font-size: 14px; }
ol.plist .pbody small { display: block; color: var(--text-dim); font-size: 12.5px; margin-top: 2px; font-weight: 400; }
ol.plist .prole { color: var(--gold); font-size: 12.5px; font-weight: 600; white-space: nowrap; }
@media (max-width: 560px) {
  ol.plist > li { grid-template-columns: 1fr auto; }
  ol.plist .period { grid-column: 1 / -1; }
}

.link-btns { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 14px; }
.link-btn {
  display: inline-flex; align-items: center; gap: 7px;
  font-weight: 600; font-size: 14px;
  color: var(--text); text-decoration: none;
  background: rgba(255,255,255,.05);
  border: 1px solid var(--panel-edge);
  padding: 9px 16px 8px; border-radius: 10px;
  transition: transform .1s, border-color .15s, color .15s;
}
.link-btn:hover { transform: translateY(-1px); border-color: var(--gold); color: var(--gold-soft); }
.link-btn:active { transform: translateY(1px); }

ol.flow-steps { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 8px; list-style: none; margin: 0; padding: 0; counter-reset: step; }
ol.flow-steps > li {
  background: rgba(13,14,19,.55);
  border: 1px solid rgba(255,255,255,.07);
  border-radius: 10px; padding: 11px 12px 10px;
  text-align: center;
}
ol.flow-steps .num { color: var(--steel); font-size: 11px; letter-spacing: .22em; font-weight: 600; }
ol.flow-steps strong { display: block; font-weight: 700; font-size: 16px; color: var(--gold-soft); margin: 3px 0 5px; }
ol.flow-steps p { font-size: 12.5px; color: var(--text-dim); line-height: 1.65; margin: 0; }

aside.note {
  margin-top: 16px; font-size: 13px; color: var(--text-dim); line-height: 1.7;
  background: rgba(147,167,196,.06);
  border: 1px solid rgba(147,167,196,.18);
  border-radius: 10px; padding: 11px 13px;
}
aside.note a { color: var(--gold); }

/* ---------- 모바일 최적화 ---------- */
@media (max-width: 720px) {
  .hud-name { font-size: 14px; padding: 5px 10px 4px; border-radius: 10px; }
  .hud-name .hud-title { display: none; }
  .nav-btn { font-size: 12px; padding: 6px 9px 5px; border-radius: 10px; }
  .icon-btn { width: 34px; height: 34px; }
  #dialog {
    width: calc(100vw - 20px);
    max-height: 86dvh;
    border-radius: 12px;
  }
  .dialog-head { padding: 12px 12px 10px 14px; gap: 8px; }
  #dialog-title { font-size: 17px; }
  .dialog-eyebrow { font-size: 9.5px; letter-spacing: .18em; }
  .dialog-body { padding: 14px 14px 18px; font-size: 15px; }
  .title-card { padding: 30px 22px 24px; border-radius: 14px; }
  .title-main { font-size: clamp(26px, 7.5vw, 36px); }
  .title-help { font-size: 11.5px; gap: 6px 14px; }
  #joystick { width: 108px; height: 108px; left: 18px; bottom: 24px; }
  #joystick-knob { width: 48px; height: 48px; }
  #btn-action { width: 68px; height: 68px; font-size: 22px; right: 20px; bottom: 38px; }
  .flow-steps { grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); }
}

button:focus-visible, a:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }

.title-alt { margin-top: 14px; font-family: var(--font-read); font-size: 13px; }
.title-alt a { color: var(--steel); text-decoration: none; border-bottom: 1px solid rgba(147,167,196,.35); padding-bottom: 1px; transition: color .15s, border-color .15s; }
.title-alt a:hover { color: var(--gold-soft); border-color: var(--gold); }
