:root {
  --bg: #1d2230; --panel: #272e40; --line: #3a445c; --text: #eef0f4; --dim: #a8b1c4;
  --accent: #f0a058; --ok: #7fd1a0; --bad: #f08a80;
  font-family: "Pretendard", "Malgun Gothic", system-ui, sans-serif;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font-size: 15px; line-height: 1.5; }
.app { max-width: 960px; margin: 0 auto; padding: 16px; }
.top { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
h1 { font-size: 22px; margin: 0; white-space: nowrap; }
h2 { font-size: 13px; color: var(--dim); margin: 0 0 8px; font-weight: 600; }
.clock { margin-left: auto; color: var(--dim); font-variant-numeric: tabular-nums; }
.pill { font-size: 13px; padding: 2px 10px; border-radius: 99px; background: var(--line); color: var(--dim); }
.pill.ok { background: #254a3a; color: var(--ok); }
.pill.bad { background: #54302f; color: var(--bad); }

.stage { position: relative; aspect-ratio: 16 / 9; width: 100%; background: #000; border-radius: 8px; overflow: hidden; }
canvas { display: block; width: 100%; height: 100%; image-rendering: pixelated; }
.bubble {
  position: absolute; max-width: 46%; padding: 8px 12px; background: #fffdf6; color: #2a2733;
  border: 3px solid #2a2733; font-size: clamp(12px, 1.5vw, 16px); line-height: 1.4; white-space: pre-line;
  transform: translate(-50%, -100%); pointer-events: none;
}
.bubble::after {
  content: ""; position: absolute; left: 50%; bottom: -10px; width: 10px; height: 10px;
  margin-left: -5px; background: #fffdf6; border-right: 3px solid #2a2733; border-bottom: 3px solid #2a2733;
  transform: rotate(45deg) scale(.75);
}
.bubble.alert { border-color: #c8562f; background: #fff3dc; font-weight: 600; }
.pipBack { position: absolute; right: 6px; top: 6px; }

.actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
button {
  font: inherit; color: var(--text); background: var(--panel); border: 1px solid var(--line);
  border-radius: 6px; padding: 8px 14px; cursor: pointer;
}
button:hover { border-color: var(--dim); }
button:focus-visible, input:focus-visible, a:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
button.primary { background: var(--accent); border-color: var(--accent); color: #2a1a0c; font-weight: 700; }
button:disabled { opacity: .55; cursor: default; }
.order { display: flex; gap: 8px; margin-top: 12px; }
.order input { flex: 1; min-width: 0; }
.order button { flex: 0 0 auto; }
.pushBtns:not([hidden]) { display: flex; gap: 8px; }
.events li button { margin-left: auto; flex: 0 0 auto; padding: 0 8px; font-size: 12px; }
.warn { color: var(--bad); margin: 10px 0 0; }
.hint { color: var(--dim); font-size: 13px; margin: 10px 0 0; }

.card { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 14px; }
.steps { margin: 0 0 10px; padding-left: 20px; font-size: 14px; }
.steps a { color: var(--accent); }
label { display: block; font-size: 13px; color: var(--dim); margin-bottom: 4px; }
input { width: 100%; font: inherit; color: var(--text); background: var(--bg); border: 1px solid var(--line); border-radius: 6px; padding: 8px 10px; }
.small { font-size: 12.5px; color: var(--dim); margin: 6px 0 10px; }
.row { display: flex; gap: 8px; }
.next { margin: 0; font-weight: 600; white-space: pre-line; }
.events, .log { list-style: none; margin: 0 0 12px; padding: 0; }
.events:last-child, .log:last-child { margin-bottom: 0; }
.events li { display: flex; gap: 10px; padding: 3px 0; overflow-wrap: anywhere; }
.events time { color: var(--accent); font-variant-numeric: tabular-nums; flex: 0 0 auto; }
.events li.past { color: var(--dim); text-decoration: line-through; }
.events li.empty, .log li.empty { color: var(--dim); }
.log { max-height: 200px; overflow-y: auto; font-size: 13px; }
.log li { padding: 3px 0; border-top: 1px solid var(--line); overflow-wrap: anywhere; }
.log li:first-child { border-top: 0; }
.log span { color: var(--dim); }
.copy { display: flex; align-items: center; justify-content: center; gap: 6px; font-size: 12px; color: var(--dim); padding: 4px 0; }
.copy img { height: 11px; width: auto; }

#weather { margin-left: auto; }
#weather + .clock { margin-left: 0; }
dialog { max-width: 560px; width: calc(100% - 32px); background: var(--panel); color: var(--text); border: 1px solid var(--line); border-radius: 10px; padding: 20px; }
dialog::backdrop { background: rgba(10, 12, 20, .7); }
dialog h2 { font-size: 18px; color: var(--text); margin-bottom: 12px; }
fieldset { border: 0; margin: 0 0 14px; padding: 0; }
legend { font-size: 13px; color: var(--dim); margin-bottom: 6px; }
.choices { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.choice { display: block; position: relative; margin: 0; padding: 8px 10px; border: 1px solid var(--line); border-radius: 6px; cursor: pointer; color: var(--text); font-size: 14px; }
.choice input { position: absolute; opacity: 0; }
.choice small { display: block; color: var(--dim); font-size: 12px; margin-top: 2px; }
.choice:has(input:checked) { border-color: var(--accent); background: #3a3330; }
.choice:has(input:focus-visible) { outline: 2px solid var(--accent); }
.roomName { position: absolute; left: 8px; top: 8px; padding: 2px 8px; border-radius: 4px; background: rgba(20, 22, 32, .72); font-size: 13px; }
.roomHint { position: absolute; left: 50%; top: 8px; transform: translateX(-50%); padding: 3px 10px; border-radius: 4px; background: rgba(20, 22, 32, .78); font-size: 13px; white-space: nowrap; }
.nav { position: absolute; top: 50%; transform: translateY(-50%); background: rgba(20, 22, 32, .72); border-color: rgba(255, 255, 255, .25); font-size: 14px; }
.nav.prev { left: 8px; }
.nav.next { right: 8px; }
.decor fieldset { margin-bottom: 8px; }
.decor fieldset:last-child { margin-bottom: 0; }
.decor .choices { grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 6px; }
.decor .choice { padding: 5px 8px; font-size: 13px; }
.pip .nav { font-size: 11px; padding: 3px 6px; }
.pip .roomName { display: none; }
.pip .roomHint { font-size: 11px; top: 4px; }
.dex li { font-size: 13px; }
.guide .row { flex-wrap: wrap; }
.closeBar { height: 8px; border-radius: 4px; background: var(--line); overflow: hidden; margin: 6px 0 10px; }
.closeBar i { display: block; height: 100%; background: var(--accent); }
.dexTabs { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 8px; }
.dexTabs button { padding: 3px 8px; font-size: 12px; }
.dexTabs button[aria-selected="true"] { border-color: var(--accent); color: var(--accent); }
.dex { max-height: 260px; overflow-y: auto; }
.dex li.unknown small { color: var(--dim); }
.vol { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--dim); padding: 0 6px; }
.vol input { width: 110px; accent-color: var(--accent); }
.vol span { min-width: 34px; font-variant-numeric: tabular-nums; }
.dex li.unknown { color: var(--dim); }
.monitor.video, .monitor.sns { padding: 0; min-height: 0; }
.monitor.video canvas, .monitor.sns canvas { display: block; width: 100%; image-rendering: pixelated; }
.nagBar { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.bossLine { position: absolute; left: 50%; bottom: 8px; transform: translateX(-50%); padding: 4px 12px; border-radius: 4px; background: rgba(40, 20, 24, .88); border: 1px solid #8a4a44; font-size: 14px; white-space: nowrap; }
.nagLabel { font-size: 13px; color: var(--dim); }
.chatBtns:not([hidden]) { position: absolute; left: 50%; bottom: 8px; transform: translateX(-50%); display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; width: 96%; }
.chatBtns button { padding: 5px 10px; font-size: 13px; }
.pip .chatBtns button { padding: 3px 6px; font-size: 11px; }
.nagBtns { display: flex; flex-wrap: wrap; gap: 6px; }
.nagBtns button { padding: 5px 10px; font-size: 13px; background: #3b2a2e; border-color: #6a4448; }
.nagBtns button.hit { background: #6a2f2f; border-color: var(--bad); font-weight: 700; }
.nagBtns .none { font-size: 13px; color: var(--dim); }
.guide summary { cursor: pointer; font-weight: 700; color: var(--accent); }
.guide .steps { margin-top: 8px; }
.lock { color: var(--dim); font-size: 11px; display: block; }
canvas.poke { cursor: pointer; }
.scold { background: #5a2f2f; border-color: #8a4a44; }
.scold:not(:disabled):hover { border-color: var(--bad); }
.cctv { position: absolute; left: 40%; top: 0.5%; width: 8%; height: 9%; padding: 0; background: transparent; border: 1px dashed transparent; border-radius: 3px; }
.cctv:hover, .cctv:focus-visible { border-color: rgba(255, 255, 255, .7); }
.cctvDlg { max-width: 460px; background: #10131c; }
.cctvTop { display: flex; gap: 10px; font-size: 12px; color: var(--dim); margin-bottom: 8px; font-variant-numeric: tabular-nums; }
.cctvTop .rec { color: #ff5a5a; }
.cctvTop span:last-child { margin-left: auto; }
.monitor { background: #0b1a24; border: 6px solid #2b2f3a; border-radius: 4px; min-height: 190px; padding: 12px; font-size: 14px; color: #cfe8f0; filter: saturate(.8); }
.monitor h3 { margin: 0 0 8px; font-size: 15px; color: #fff; }
.monitor ul { margin: 0; padding-left: 18px; }
.monitor .bar { height: 8px; margin: 8px 0; background: #284050; border-radius: 4px; overflow: hidden; }
.monitor .bar i { display: block; height: 100%; background: #e55; }
.monitor.shop { padding: 0; background: #fff; min-height: 0; }
.monitor.shop canvas { display: block; width: 100%; image-rendering: pixelated; }
.monitor.away { display: grid; place-items: center; color: #7a8a96; }
.monitor.job h3 { color: #ffd479; }
.monitor.resign { background: #f4f1ea; color: #222; }
.monitor.resign h3 { color: #111; text-align: center; letter-spacing: 6px; }
.cctvDlg form { margin-top: 10px; text-align: right; }
.letter { position: relative; background: #f6f2e8; color: #2a2733; padding: 18px 20px; border-radius: 4px; margin-bottom: 12px; }
.letter h2 { color: #2a2733; text-align: center; letter-spacing: 8px; }
.letter .small { color: #6a6470; }
.stamp { position: absolute; right: 18px; bottom: 14px; padding: 6px 10px; border: 3px solid #c8322c; color: #c8322c; font-weight: 800; font-size: 20px; border-radius: 6px; transform: rotate(-12deg); animation: stamp .25s ease-out; }
@keyframes stamp { from { transform: rotate(-12deg) scale(2.2); opacity: 0; } to { transform: rotate(-12deg) scale(1); opacity: 1; } }
.bubble.narration { background: #2f3446; color: #e8e8f0; border-color: #6a7088; font-style: italic; }
.bubble.narration::after { background: #2f3446; border-color: #6a7088; }
.pip { margin: 0; background: #000; overflow: hidden; }
.pip .stage { position: fixed; inset: 0; width: auto; aspect-ratio: auto; border-radius: 0; }
.pip canvas { object-fit: cover; }
.pip .pipBack { padding: 2px 8px; font-size: 12px; opacity: .85; }
.pip .bubble { font-size: 13px; max-width: 74%; padding: 5px 8px; }

@media (max-width: 900px) { .app { padding: 12px; } .bubble { font-size: 12px; } .dock span { display: none; } .top .next { display: none; } }
@media (prefers-reduced-motion: reduce) { * { scroll-behavior: auto; } }

/* 서랍: 평소엔 아이콘만, 누르면 작은 팝업 (바깥 누르거나 Esc 로 닫힘) */
.top .next { margin: 0 0 0 8px; font-size: 13px; font-weight: 500; color: var(--dim); white-space: normal; min-width: 0; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 1; -webkit-box-orient: vertical; }
.dock { display: flex; gap: 4px; margin-left: auto; }
.dock button { display: flex; align-items: center; gap: 4px; padding: 5px 8px; font-size: 14px; background: transparent; border-color: transparent; }
.dock button:hover { background: var(--panel); border-color: var(--line); }
.dock span { font-size: 12px; color: var(--dim); }
.pop { width: min(340px, calc(100vw - 32px)); max-height: min(70vh, 560px); overflow-y: auto; margin: 0; inset: auto 16px 16px auto;
  background: var(--panel); color: var(--text); border: 1px solid var(--line); border-radius: 10px; padding: 14px; box-shadow: 0 12px 40px rgba(0, 0, 0, .45); }
.pop::backdrop { background: transparent; }
/* 지원 브라우저(Chrome·Edge)에선 누른 아이콘 바로 위에 붙는다. 아니면 오른쪽 아래 */
@supports (position-area: top) { .pop { inset: auto; margin: 0 0 6px; position-area: top span-left; position-try-fallbacks: flip-block; } }
.pop h2 { margin-top: 4px; }
.pop .actions { margin-top: 0; }
.pop .guide { margin-top: 12px; }
.pop .copy { margin-top: 10px; }
.pop #connect { margin-bottom: 12px; }
.pop .dex { max-height: none; }
.pop details > summary { cursor: pointer; }

/* 보스 키: 누가 오면 엑셀 화면 */
.boss { position: fixed; inset: 0; z-index: 9999; background: #fff; color: #222; font: 13px "Malgun Gothic", "Segoe UI", sans-serif; overflow: hidden; }
.bossBar { background: #217346; color: #fff; padding: 6px 12px; }
.bossBar b { background: #fff; color: #217346; padding: 0 5px; margin-right: 6px; border-radius: 2px; }
.bossBar span { opacity: .75; }
.bossMenu { background: #f3f3f3; padding: 6px 12px; border-bottom: 1px solid #d4d4d4; color: #444; }
.bossFx { padding: 4px 12px; border-bottom: 1px solid #d4d4d4; color: #444; }
.bossFx span { display: inline-block; width: 60px; border-right: 1px solid #d4d4d4; margin-right: 8px; }
.boss table { border-collapse: collapse; width: 100%; table-layout: fixed; }
.boss td { border: 1px solid #e1e1e1; height: 21px; padding: 0 4px; white-space: nowrap; overflow: hidden; }
.boss td:first-child, .boss tr:first-child td { background: #f3f3f3; color: #666; text-align: center; }
.boss td:first-child { width: 40px; }
.boss td.n { text-align: right; }

/* 도움말: 평소엔 설명·힌트를 숨기고, ❓ 를 켜면 보인다 */
body:not(.help) .tip { display: none !important; }
#btnHelp[aria-pressed="true"] { background: #3a3330; border-color: var(--accent); }
.legend { list-style: none; margin: 0 0 12px; padding: 0; font-size: 13px; }
.legend li { padding: 2px 0; }
.legend b { color: var(--accent); margin-right: 4px; }
.linkBtn { padding: 0 4px; border: 0; background: none; color: var(--accent); font-size: 12.5px; text-decoration: underline; }

/* 호감 레벨 배지 · 미션 완료 알림 */
.lvBadge { position: absolute; right: 8px; top: 8px; padding: 2px 8px; border-radius: 4px; background: rgba(20, 22, 32, .72); border-color: rgba(255, 255, 255, .2); font-size: 13px; font-variant-numeric: tabular-nums; }
.lvBadge:hover { border-color: var(--accent); }
.toast { position: absolute; left: 50%; top: 40px; transform: translateX(-50%); padding: 4px 12px; border-radius: 4px; background: rgba(60, 44, 20, .92); border: 1px solid var(--accent); color: #ffe6c4; font-size: 13px; white-space: nowrap; animation: toastIn .25s ease-out; }
@keyframes toastIn { from { transform: translate(-50%, -8px); opacity: 0; } }
.hearts { color: #ff7a90; letter-spacing: 1px; }
.missions li { justify-content: space-between; }
.missions li.done { color: var(--ok); }
.missions time { color: var(--dim); }
.pip .lvBadge { font-size: 11px; padding: 1px 6px; top: 4px; right: 4px; }
.pip .toast { font-size: 11px; top: 26px; }

/* 엑셀 위장 화면 아래 시트 탭 + 돌아가기 */
.bossTabs { position: absolute; left: 0; right: 0; bottom: 0; display: flex; align-items: stretch; gap: 0; background: #f3f3f3; border-top: 1px solid #d4d4d4; font-size: 12px; color: #444; }
.bossTabs span { padding: 5px 14px; border-right: 1px solid #d4d4d4; }
.bossTabs span.on { background: #fff; color: #217346; font-weight: 700; border-bottom: 2px solid #217346; }
.bossTabs button { margin-left: auto; border-radius: 0; border: 0; border-left: 1px solid #d4d4d4; background: #217346; color: #fff; font-size: 13px; font-weight: 700; padding: 6px 16px; }
.bossTabs button:hover { background: #185c37; }
.bossTabs kbd { font: 11px inherit; opacity: .75; border: 1px solid rgba(255, 255, 255, .5); border-radius: 3px; padding: 0 4px; margin-left: 4px; }
@media (max-width: 600px) { .bossTabs span:not(.on) { display: none; } .bossTabs kbd { display: none; } .roomHint { top: 34px; font-size: 12px; } }
@media (max-width: 600px) {
  .top { flex-wrap: wrap; gap: 4px 10px; }
  h1 { font-size: 18px; }
  .clock, .pill { white-space: nowrap; font-size: 12px; }
  .bubble { max-width: 72%; font-size: 11px; padding: 4px 7px; border-width: 2px; }
  .lvBadge, .roomName { font-size: 11px; padding: 1px 6px; top: 6px; }
  .nav { font-size: 11px; padding: 4px 7px; }
  .dock { justify-content: space-between; width: 100%; margin-left: 0; gap: 0; }
  .dock button { padding: 8px 6px; font-size: 17px; min-width: 40px; justify-content: center; }
}
.notFound { text-align: center; padding-top: 15vh; } .notFound a { color: var(--accent); }
