:root {
  --bg: #0b1220;
  --panel: #111a2b;
  --line: #1f2c44;
  --text: #e6edf7;
  --muted: #8b9bb4;
  --accent: #f87171;       /* 연한 빨강 — 강조 */
  --accent-dim: #d94f4f;   /* 버튼 배경. 흰 글씨 대비를 확보하려고 한 단계 진하게 */
  --danger: #fbbf24;       /* 경고는 강조색과 겹치지 않게 앰버로 */
}

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

/* display 를 지정한 요소는 hidden 속성이 무시된다. JS 가 hidden 으로 껐다 켜므로 되살린다. */
[hidden] { display: none !important; }

html, body { height: 100%; }

body {
  font-family: 'Pretendard', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  overflow: hidden;
}

.app { display: flex; height: 100vh; height: 100dvh; }

/* ---------- 패널 ---------- */

.panel {
  width: 340px;
  flex: 0 0 340px;
  background: var(--panel);
  border-right: 1px solid var(--line);
  padding: 24px 20px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  overflow-y: auto;
  transition: margin-left .25s ease;
}

.panel__head h1 { font-size: 19px; font-weight: 700; letter-spacing: -.3px; }
.panel__head p { font-size: 13px; color: var(--muted); margin-top: 6px; line-height: 1.6; }

.panel__foot {
  margin-top: auto;
  padding-top: 16px;
  border-top: 1px solid var(--line);
  font-size: 12px;
  color: var(--muted);
  line-height: 1.5;
  word-break: keep-all;
}

.notice {
  padding: 12px 14px;
  border-radius: 10px;
  font-size: 13px;
  line-height: 1.6;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.notice--error { background: rgba(251, 191, 36, .12); border: 1px solid rgba(251, 191, 36, .3); color: #fcd34d; }
.notice code { background: rgba(0, 0, 0, .3); padding: 1px 5px; border-radius: 4px; font-size: 12px; }

/* ---------- 입력 ---------- */

.field { display: flex; flex-direction: column; gap: 7px; position: relative; }
.field > label { font-size: 12px; font-weight: 600; color: var(--muted); }
.field__row { display: flex; gap: 6px; }

input[type=text] {
  flex: 1;
  min-width: 0;
  background: #0c1526;
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 11px 12px;
  color: var(--text);
  font-size: 14px;
  font-family: inherit;
}
input[type=text]:focus { outline: none; border-color: var(--accent-dim); }
input[type=text]::placeholder { color: #55627a; }

.results {
  list-style: none;
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  z-index: 40;
  margin-top: 4px;
  background: #0c1526;
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
  box-shadow: 0 12px 32px rgba(0, 0, 0, .5);
  max-height: 260px;
  overflow-y: auto;
}
.results li { padding: 10px 12px; cursor: pointer; display: flex; flex-direction: column; gap: 2px; }
.results li:hover { background: #16223a; }
.results strong { font-size: 13px; font-weight: 600; }
.results span { font-size: 11.5px; color: var(--muted); }

.picked { font-size: 12px; color: var(--accent); line-height: 1.5; word-break: keep-all; }

/* ---------- 버튼 ---------- */

.btn {
  background: #1b273e;
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: 9px;
  padding: 11px 14px;
  font-size: 14px;
  font-family: inherit;
  font-weight: 600;
  cursor: pointer;
  transition: filter .15s ease;
}
.btn:hover:not(:disabled) { filter: brightness(1.25); }
.btn:disabled { opacity: .4; cursor: not-allowed; }
.btn--primary { background: var(--accent-dim); border-color: var(--accent); }
.btn--ghost { background: transparent; flex: 0 0 auto; font-size: 12.5px; padding: 11px 12px; }

/* ---------- 진행률 / 컨트롤 ---------- */

.progress { display: flex; flex-direction: column; gap: 8px; }
.progress__bar { height: 6px; background: #0c1526; border-radius: 99px; overflow: hidden; }
.progress__bar span { display: block; height: 100%; width: 0; background: var(--accent); transition: width .2s ease; }
.progress__label { font-size: 12px; color: var(--muted); }

.controls { display: flex; flex-direction: column; gap: 16px; }
.controls__row { display: flex; gap: 8px; }
.controls__row .btn--primary { flex: 1; }

.slider { display: flex; flex-direction: column; gap: 7px; font-size: 12px; color: var(--muted); }
.slider b { color: var(--text); }
.slider input { width: 100%; accent-color: var(--accent); }

.toggle { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); cursor: pointer; }
.toggle input { accent-color: var(--accent); width: 15px; height: 15px; }
kbd {
  background: #0c1526; border: 1px solid var(--line); border-bottom-width: 2px;
  border-radius: 4px; padding: 1px 5px; font-size: 10.5px; font-family: inherit;
}

.summary { font-size: 12.5px; color: var(--muted); }

/* ---------- 무대 ---------- */

.stage { flex: 1; position: relative; background: #05080f; min-width: 0; }
.roadview { position: absolute; inset: 0; }

.stage__empty {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  color: var(--muted); font-size: 14px; pointer-events: none; text-align: center; padding: 24px;
}

.minimap {
  position: absolute;
  left: 16px; bottom: 16px;
  width: 190px; height: 190px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, .15);
  overflow: hidden;
  box-shadow: 0 10px 30px rgba(0, 0, 0, .55);
  z-index: 5;
}

.hud {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  padding: 14px 18px;
  background: linear-gradient(to top, rgba(0, 0, 0, .65), transparent);
  display: flex; align-items: center; gap: 12px;
  z-index: 6;
}
.hud__bar { flex: 1; height: 4px; background: rgba(255, 255, 255, .2); border-radius: 99px; overflow: hidden; }
.hud__bar span { display: block; height: 100%; width: 0; background: var(--accent); transition: width .25s linear; }
.hud__meta { font-size: 12px; color: #cbd5e1; font-variant-numeric: tabular-nums; }

.stage__exit {
  position: absolute; top: 16px; left: 52px; z-index: 7;
  background: rgba(0, 0, 0, .55); color: #fff;
  border: 1px solid rgba(255, 255, 255, .2); border-radius: 99px;
  padding: 8px 14px; font-size: 12.5px; font-family: inherit; cursor: pointer;
  backdrop-filter: blur(6px);
}

/* ---------- 패널 접기 손잡이 ---------- */

.stage__toggle {
  position: absolute;
  left: 10px; top: 50%;
  transform: translateY(-50%);
  z-index: 8;
  width: 26px; height: 56px;
  padding: 0;
  display: flex; align-items: center; justify-content: center;
  background: rgba(0, 0, 0, .5);
  border: 1px solid rgba(255, 255, 255, .18);
  border-radius: 8px;
  color: #e2e8f0;
  cursor: pointer;
  backdrop-filter: blur(6px);
  transition: background .15s ease;
}
.stage__toggle:hover { background: rgba(0, 0, 0, .72); }
.stage__toggle svg { width: 14px; height: 14px; transition: transform .25s ease; }
body.is-collapsed .stage__toggle svg { transform: rotate(180deg); }

/* ---------- 접힘 / 시네마 모드 ---------- */

body.is-collapsed .panel { margin-left: -340px; }
body.is-cinema .minimap { opacity: 0; pointer-events: none; }

/* ---------- 모바일 ---------- */

@media (max-width: 780px) {
  .app { flex-direction: column-reverse; }
  .panel {
    width: 100%; flex: 0 0 auto; max-height: 52vh;
    border-right: none; border-top: 1px solid var(--line);
  }
  .stage { flex: 1; min-height: 48vh; }
  /* 세로 배치에서는 좌우 마진으로 못 접으므로 그냥 숨긴다 */
  body.is-collapsed .panel { margin-left: 0; display: none; }
  .minimap { width: 128px; height: 128px; left: 12px; bottom: 12px; }

  /* 손잡이는 아래쪽 가운데로 내리고 화살표를 세운다 */
  .stage__toggle {
    left: 50%; top: auto; bottom: 10px;
    transform: translateX(-50%) rotate(-90deg);
  }
  .stage__exit { left: 16px; }
}
