:root {
  --bg: rgba(14, 20, 28, 0.86);
  --bg-2: rgba(255, 255, 255, 0.06);
  --line: rgba(255, 255, 255, 0.12);
  --fg: #e8edf2;
  --muted: #93a1b0;
  --accent: #4fb3ff;
  --accent-2: #ffd166;
  --danger: #ff6b6b;
  font-family: "Pretendard", "Apple SD Gothic Neo", "Noto Sans KR", system-ui, sans-serif;
}

html, body { margin: 0; height: 100%; overflow: hidden; background: #000; color: var(--fg); }
#viewer { position: absolute; inset: 0; }
.cesium-viewer-bottom { left: auto !important; right: 8px; bottom: 92px !important; }

button, select, input { font: inherit; color: inherit; }
button {
  background: var(--bg-2); border: 1px solid var(--line); border-radius: 6px;
  padding: 6px 10px; cursor: pointer;
}
button:hover { border-color: var(--accent); }
button.primary { background: var(--accent); color: #04121f; border-color: var(--accent); font-weight: 600; }
button.active { border-color: var(--accent); color: var(--accent); }

#panel {
  position: absolute; top: 12px; left: 12px; width: 300px; max-height: calc(100% - 120px);
  overflow: auto; background: var(--bg); border: 1px solid var(--line); border-radius: 10px;
  padding: 12px; box-sizing: border-box; backdrop-filter: blur(6px); font-size: 13px;
  transition: transform .2s;
}
#panel.collapsed { transform: translateX(calc(-100% + 34px)); }
#panel header { display: flex; justify-content: space-between; align-items: center; }
#panel h1 { font-size: 15px; margin: 0; }
#panel h2 { font-size: 12px; margin: 14px 0 6px; color: var(--muted); font-weight: 600; letter-spacing: .02em; }
#panel h2 small { font-weight: 400; }
#panel label { display: block; margin: 6px 0; color: var(--muted); }
#panel select, #panel input[type=password] {
  display: block; width: 100%; margin-top: 3px; box-sizing: border-box;
  background: rgba(0,0,0,.35); border: 1px solid var(--line); border-radius: 6px; padding: 5px 6px;
}
#panel label.check, #panel label.slider { display: flex; align-items: center; gap: 8px; }
#panel label.slider input { flex: 1; }
#panel details { margin-top: 14px; border-top: 1px solid var(--line); padding-top: 8px; }
#panel summary { cursor: pointer; color: var(--muted); }
.hint { color: var(--muted); font-size: 12px; margin: 6px 0; }
.row { display: flex; gap: 6px; margin: 8px 0; }
.row button { flex: 1; }

.route-list { display: grid; gap: 6px; }
.route-list button { text-align: left; padding: 8px 10px; }
.route-list button b { display: block; font-size: 13px; }
.route-list button span { display: block; font-size: 11px; color: var(--muted); margin-top: 2px; }
.route-list button.active { background: rgba(79,179,255,.12); }

.poi-list { display: flex; flex-wrap: wrap; gap: 5px; }
.poi-list button { font-size: 12px; padding: 4px 8px; }

.status { font-size: 11px; color: var(--muted); margin-top: 6px; line-height: 1.5; }
.status .warn { color: var(--accent-2); }

#camera-modes {
  position: absolute; top: 12px; right: 12px; display: flex; gap: 4px;
  background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 5px;
}

#hud {
  position: absolute; left: 50%; bottom: 12px; transform: translateX(-50%);
  display: flex; gap: 2px; background: var(--bg); border: 1px solid var(--line);
  border-radius: 10px; padding: 6px; font-variant-numeric: tabular-nums;
}
.hud-cell { display: flex; flex-direction: column; align-items: center; min-width: 72px; padding: 2px 8px; }
.hud-cell + .hud-cell { border-left: 1px solid var(--line); }
.hud-cell.wide { min-width: 180px; }
.hud-cell .lbl { font-size: 10px; color: var(--muted); }
.hud-cell > span:nth-child(2) { font-size: 20px; font-weight: 600; }
.hud-cell .unit { font-size: 10px; color: var(--muted); }
.progress { width: 100%; height: 6px; background: var(--bg-2); border-radius: 3px; margin: 7px 0 4px; overflow: hidden; }
.progress div { height: 100%; width: 0; background: var(--accent); }

#controls-help {
  position: absolute; right: 12px; top: 60px; background: var(--bg); border: 1px solid var(--line);
  border-radius: 10px; padding: 10px 12px; font-size: 12px; display: flex; flex-direction: column; gap: 3px;
}
#controls-help[hidden] { display: none; }

#toast {
  position: absolute; top: 20px; left: 50%; transform: translateX(-50%);
  background: var(--bg); border: 1px solid var(--accent-2); color: var(--fg);
  padding: 8px 14px; border-radius: 8px; font-size: 13px; max-width: 80vw;
}
#toast.danger { border-color: var(--danger); }

@media (max-width: 720px) {
  #panel { width: calc(100% - 24px); max-height: 45%; }
  #hud { width: calc(100% - 24px); overflow-x: auto; }
  .hud-cell { min-width: 58px; }
  #camera-modes { top: auto; bottom: 90px; }
}

#loading {
  position: absolute; left: 50%; top: 45%; transform: translate(-50%, -50%);
  display: flex; align-items: center; gap: 10px; background: var(--bg);
  border: 1px solid var(--line); border-radius: 10px; padding: 12px 16px; font-size: 14px;
}
#loading[hidden] { display: none; }
.spinner {
  width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--line);
  border-top-color: var(--accent); animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

#panel h1 small { font-size: 11px; color: var(--muted); font-weight: 400; }
.route-list button .meta { display: flex; justify-content: space-between; margin-top: 3px; }
.route-list button .swatch { display: inline-block; width: 8px; height: 8px; border-radius: 2px; margin-right: 5px; }
#controls-help em { font-style: normal; color: var(--muted); margin-top: 4px; line-height: 1.5; }

#objective {
  position: absolute; top: 60px; left: 50%; transform: translateX(-50%);
  display: flex; align-items: center; gap: 10px; background: var(--bg);
  border: 1px solid var(--line); border-radius: 10px; padding: 6px 14px 6px 10px;
}
#objective[hidden] { display: none; }
#objective b { display: block; font-size: 14px; }
#objective span#obj-dist { font-size: 12px; color: var(--muted); }
#obj-arrow { font-size: 22px; color: var(--accent-2); display: inline-block; transition: transform .1s linear; }

#banner {
  position: absolute; top: 38%; left: 50%; transform: translate(-50%, -50%);
  background: var(--bg); border: 1px solid var(--accent); border-radius: 14px;
  padding: 18px 26px; text-align: center; font-size: 15px; line-height: 1.6;
}
#banner[hidden] { display: none; }
#banner b { display: block; font-size: 24px; margin-bottom: 4px; }
#banner button { margin: 10px 4px 0; }

#hangar summary { font-weight: 600; color: var(--fg); }
#panel input[type=text] {
  display: block; width: 100%; margin-top: 3px; box-sizing: border-box;
  background: rgba(0,0,0,.35); border: 1px solid var(--line); border-radius: 6px; padding: 5px 6px;
}
#panel input[type=file] { display: block; margin-top: 4px; font-size: 12px; max-width: 100%; }
.color-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.color-grid label { font-size: 11px; text-align: center; margin: 0 !important; }
.color-grid input[type=color] {
  display: block; width: 100%; height: 28px; margin-top: 3px; padding: 0;
  border: 1px solid var(--line); border-radius: 6px; background: none; cursor: pointer;
}
#hg-presets { margin-top: 8px; }
#hg-presets .swatch { display: inline-block; width: 8px; height: 8px; border-radius: 2px; margin-right: 5px; }
#panel label[hidden] { display: none; }

#hg-teams button { display: flex; align-items: center; gap: 10px; }
#hg-teams img { width: 34px; height: 34px; flex: none; }
#hg-teams button div { min-width: 0; }
#hg-team-info { border: 1px dashed var(--line); border-radius: 8px; padding: 8px; }
#hg-kids button { display: flex; flex-direction: column; align-items: stretch; gap: 6px; }
#hg-kids img { width: 100%; height: auto; border-radius: 6px; background: #fff; }
#hg-paint[hidden] { display: none; }

/* 조종석 계기판 */
#cockpit { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 1; }
#cockpit[hidden] { display: none; }
#panel, #camera-modes, #controls-help, #toast, #banner, #loading { z-index: 3; }
.cesium-viewer-bottom { z-index: 2; }
body.cockpit-on #hud, body.cockpit-on #objective { display: none; }
body.cockpit-on .cesium-viewer-bottom { bottom: 8px !important; opacity: 0.7; }

/* 하늘 효과 */
#fx-tint { position: absolute; inset: 0; background: #2b3340; mix-blend-mode: multiply; opacity: 0; pointer-events: none; z-index: 1; transition: opacity 1s; }
#fx-rain { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 1; }
#fx-flash { position: absolute; inset: 0; background: #fff; opacity: 0; pointer-events: none; z-index: 1; }
body.cockpit-on #fx-tint, body.cockpit-on #fx-rain, body.cockpit-on #fx-flash { z-index: 0; }

#badges { position: absolute; top: 12px; left: 50%; transform: translateX(-50%); display: flex; gap: 6px; z-index: 3; pointer-events: none; }
body.cockpit-on #badges { top: 10px; }
.badge { background: var(--bg); border: 1px solid var(--line); border-radius: 999px; padding: 4px 10px; font-size: 12px; }
.badge.ok { border-color: #3ddc84; color: #8dffc0; }
.badge.warn { border-color: var(--accent-2); color: var(--accent-2); }
.badge[hidden] { display: none; }
#objective { top: 48px; }
.stamp { display: inline-block; margin-left: 6px; filter: grayscale(1) opacity(.35); font-size: 16px; }
.stamp.on { filter: none; }

/* 교신 카드 */
#radio-card {
  position: absolute; left: 50%; transform: translateX(-50%); bottom: 96px; width: min(640px, calc(100% - 24px));
  background: rgba(14, 20, 28, .94); border: 2px solid var(--line); border-radius: 16px; padding: 12px 16px 12px;
  z-index: 4; box-shadow: 0 10px 30px rgba(0,0,0,.45); backdrop-filter: blur(6px);
}
body.cockpit-on #radio-card { bottom: calc(clamp(200px, 36vh, 360px) + 16px); }
#radio-card[hidden] { display: none; }
#radio-card.rc-prompt { border-color: var(--accent); animation: rcPulse 1.6s ease-in-out infinite; }
#radio-card.rc-playing { border-color: #8dffc0; }
@keyframes rcPulse { 50% { box-shadow: 0 0 0 5px rgba(79,179,255,.25), 0 10px 30px rgba(0,0,0,.45); } }
#radio-card.rc-kind-announce.rc-prompt { border-color: var(--accent-2); animation-name: rcPulseGold; }
@keyframes rcPulseGold { 50% { box-shadow: 0 0 0 5px rgba(255,209,102,.25), 0 10px 30px rgba(0,0,0,.45); } }
.rc-head { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); }
.rc-icon { font-size: 20px; }
.rc-role { color: var(--fg); }
.rc-tag { background: rgba(255,255,255,.08); border-radius: 999px; padding: 1px 8px; font-size: 11px; }
.rc-x { margin-left: auto; border: none; background: none; font-size: 18px; color: var(--muted); padding: 0 6px; }
.rc-en { font-size: 24px; font-weight: 700; line-height: 1.3; margin: 8px 0 4px; }
.rc-ko { font-size: 16px; color: #b9c6d4; line-height: 1.4; }
.rc-bar { height: 4px; background: rgba(255,255,255,.1); border-radius: 2px; margin: 10px 0; overflow: hidden; }
.rc-bar i { display: block; height: 100%; width: 0; background: var(--accent); transition: width .1s linear; }
.rc-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.rc-actions button { font-size: 15px; padding: 8px 14px; }
.rc-go { font-size: 18px !important; padding: 10px 18px !important; }
.rc-go kbd { font-size: 11px; background: rgba(0,0,0,.25); border-radius: 4px; padding: 1px 5px; margin-left: 6px; }
.rc-kotoggle { margin-left: auto; }
.rc-kotoggle.on { border-color: var(--accent); color: var(--accent); }

#radio-log-btn { position: absolute; left: 12px; bottom: 12px; z-index: 3; }
#radio-log { position: absolute; left: 12px; bottom: 56px; width: min(380px, calc(100% - 24px)); max-height: 55vh; overflow: auto; z-index: 5; background: var(--bg); border: 1px solid var(--line); border-radius: 12px; padding: 10px; }
#radio-log[hidden] { display: none; }
.rl-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.rl-row { display: flex; gap: 8px; padding: 6px 0; border-top: 1px solid var(--line); align-items: center; }
.rl-ic { font-size: 18px; }
.rl-en { font-size: 14px; font-weight: 600; }
.rl-ko { font-size: 12px; color: var(--muted); }
.rl-act { margin-left: auto; display: flex; gap: 4px; }
.rl-act button { padding: 3px 7px; }

/* 팀 전용기 10종: 2열 */
#hg-teams { grid-template-columns: 1fr 1fr; gap: 5px; }
#hg-teams button { padding: 6px 8px; gap: 7px; }
#hg-teams img { width: 28px; height: 28px; }
#hg-teams button b { font-size: 12px; }
#hg-teams button span { font-size: 10px; line-height: 1.25; }

/* 대답 고르기 카드 */
.rc-options { display: grid; gap: 8px; margin: 10px 0 4px; }
.rc-opt {
  display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 12px; cursor: pointer;
  background: rgba(79,179,255,.10); border: 2px solid rgba(79,179,255,.35); transition: transform .08s, border-color .1s, background .1s;
}
.rc-opt:hover { background: rgba(79,179,255,.22); border-color: var(--accent); transform: translateY(-1px); }
.rc-opt .n { flex: none; width: 24px; height: 24px; border-radius: 50%; background: var(--accent); color: #04121f; font-weight: 800; display: grid; place-items: center; font-size: 13px; }
.rc-opt .t { flex: 1; min-width: 0; }
.rc-opt b { display: block; font-size: 18px; line-height: 1.25; }
.rc-opt i { display: block; font-style: normal; font-size: 13px; color: #b9c6d4; margin-top: 2px; }
.rc-opt .pv { flex: none; padding: 5px 9px; border-radius: 8px; }
#radio-card.rc-choose { border-color: #ffd166; animation: rcPulseGold 1.8s ease-in-out infinite; }
#radio-card.rc-choose .rc-en { font-size: 20px; }

/* 무전하기 버튼·메뉴 */
#radio-talk-btn { position: absolute; left: 12px; bottom: 52px; z-index: 3; font-weight: 700; background: rgba(79,179,255,.18); border-color: var(--accent); }
#radio-talk-btn[hidden] { display: none; }
#radio-talk-btn kbd, .rc-opt kbd { font-size: 10px; background: rgba(0,0,0,.3); border-radius: 4px; padding: 1px 5px; margin-left: 4px; }
#radio-menu { position: absolute; left: 12px; bottom: 96px; width: min(400px, calc(100% - 24px)); max-height: 60vh; overflow: auto; z-index: 5; background: var(--bg); border: 2px solid var(--accent); border-radius: 14px; padding: 10px; }
#radio-menu[hidden] { display: none; }
.rm-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }
.rm-row { display: flex; align-items: center; gap: 10px; padding: 8px 8px; border-radius: 10px; cursor: pointer; border-top: 1px solid var(--line); }
.rm-row:hover { background: rgba(79,179,255,.16); }
.rm-ic { font-size: 22px; flex: none; width: 30px; text-align: center; }
.rm-t { flex: 1; min-width: 0; }
.rm-t b { display: block; font-size: 15px; }
.rm-t i { display: block; font-style: normal; font-size: 12px; color: var(--muted); }
.rm-pv { flex: none; padding: 4px 8px; }
body.cockpit-on #radio-talk-btn { bottom: 52px; }

body.radio-menu-open #radio-card { opacity: .22; pointer-events: none; }
