/* ============================================================
   AWESOME OFFICE TYCOON — 다크 픽셀 UI
   ============================================================ */
@import url('https://cdn.jsdelivr.net/npm/galmuri@latest/dist/galmuri.css');

:root {
  --bg: #101116;
  --panel: #1a1c24;
  --panel2: #22242f;
  --line: #2e313e;
  --text: #e8e8ee;
  --dim: #8a93a6;
  --green: #5ff59a;
  --blue: #5fb3f5;
  --yellow: #f5e25f;
  --red: #f55f7a;
  --purple: #b08cf5;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Galmuri9', 'DungGeunMo', 'Pretendard', sans-serif;
  font-size: 13px;
  overflow: hidden;
}
button {
  font-family: inherit; font-size: 12px; color: var(--text);
  background: var(--panel2); border: 1px solid var(--line);
  padding: 6px 10px; border-radius: 6px; cursor: pointer;
}
button:hover { border-color: var(--blue); }
button.on { background: var(--blue); color: #0b0c10; border-color: var(--blue); }
button.primary { background: var(--green); color: #0b0c10; border-color: var(--green); }
button.danger { background: var(--red); color: #0b0c10; border-color: var(--red); margin-top: 12px; }

#app { display: flex; flex-direction: column; height: 100vh; }

/* ---------- 상단바 ---------- */
#topbar {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 12px; background: var(--panel);
  border-bottom: 2px solid var(--line); flex-wrap: wrap;
}
#logo { font-weight: bold; color: var(--yellow); margin-right: 6px; white-space: nowrap; }
.pill {
  display: flex; align-items: center; gap: 6px;
  background: var(--panel2); border: 1px solid var(--line);
  border-radius: 8px; padding: 5px 10px; white-space: nowrap;
}
.pill .ic {
  display: flex; align-items: center; justify-content: center;
  width: 22px; height: 22px; border-radius: 5px; font-size: 12px;
  background: #3a3d4b; flex-shrink: 0;
}
.ic-cal { background: #c43c3c; }
.ic-money { background: #2f9e62; }
.ic-subs { background: #c43c3c; color: #fff; font-size: 10px; }
.ic-star { background: #8a6d22; }
.ic-morale { background: #2f6bc4; }
.ic-emp { background: #5d6675; }
.pill b { font-size: 13px; }
.pill .money { color: var(--green); }
.pill .subs { color: var(--red); }
.pill .rating { color: var(--yellow); }
.pill .morale { color: var(--blue); }
#speed-ctrl { margin-left: auto; display: flex; gap: 4px; }
#speed-ctrl button { padding: 5px 9px; }
#btn-auto.on { background: var(--purple); border-color: var(--purple); color: #0b0c10; }

/* ---------- 메인 ---------- */
#main { display: flex; flex: 1; min-height: 0; }
#game-area { flex: 1; display: flex; flex-direction: column; min-width: 0; padding: 8px; gap: 8px; }
#view-tabs { display: flex; gap: 5px; flex-wrap: wrap; }
#view-tabs button { font-size: 11px; padding: 6px 11px; border-radius: 7px; }
#view-tabs button.on { background: var(--yellow); color: #0b0c10; border-color: var(--yellow); }

#game-wrap {
  position: relative; width: 100%; flex: 1; min-height: 0;
  border: 2px solid var(--line); border-radius: 8px; overflow: hidden;
  background: #0c0d12; cursor: grab;
}
#game-wrap:active { cursor: grabbing; }
#game {
  position: absolute; inset: 0; width: 100%; height: 100%;
  image-rendering: pixelated;
}
#hud { position: absolute; inset: 0; pointer-events: none; }
#bubbles { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }

.bubble {
  position: absolute; transform: translate(-50%, -100%);
  background: #fffef5; color: #1a1a22;
  border: 2px solid #1a1a22; border-radius: 8px;
  padding: 4px 8px; font-size: 11px; line-height: 1.35;
  max-width: 190px; white-space: pre-wrap; word-break: keep-all;
  box-shadow: 2px 2px 0 rgba(0,0,0,0.4);
  z-index: 5; pointer-events: none;
  animation: pop .15s ease-out;
}
.bubble::after {
  content: ''; position: absolute; left: 50%; bottom: -7px;
  transform: translateX(-50%);
  border: 6px solid transparent; border-top-color: #1a1a22; border-bottom: 0;
}
@keyframes pop { from { transform: translate(-50%, -100%) scale(.6); opacity: 0; } }

/* ---------- 하단 (로그 + 메뉴) ---------- */
#bottom { display: flex; gap: 8px; height: 132px; }
#log-panel {
  flex: 1; background: var(--panel); border: 1px solid var(--line);
  border-radius: 8px; padding: 8px 10px; overflow: hidden;
  display: flex; flex-direction: column;
}
#log-panel h4 { color: var(--dim); font-size: 11px; margin-bottom: 6px; }
#log-list { overflow-y: auto; flex: 1; }
.log-row { display: flex; gap: 8px; padding: 2px 0; font-size: 11.5px; line-height: 1.4; }
.log-time { color: var(--dim); flex-shrink: 0; font-size: 10.5px; padding-top: 1px; }

#menu {
  display: grid; grid-template-columns: repeat(4, 88px); gap: 6px;
  align-content: center;
}
#menu button {
  height: 56px; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 3px;
  font-size: 11px; border-radius: 8px;
}
#menu button .mi { font-size: 19px; line-height: 1; }
#menu button:hover { background: #2a2d3a; transform: translateY(-1px); }
#menu button.on { background: var(--blue); }

/* ---------- 사이드 패널 ---------- */
#side {
  width: 300px; flex-shrink: 0; background: var(--panel);
  border-left: 2px solid var(--line); padding: 10px;
  display: flex; flex-direction: column; gap: 10px; overflow-y: auto;
}
.panel-h { font-size: 11px; color: var(--dim); letter-spacing: 1px; }

#emp-card {
  background: var(--panel2); border: 1px solid var(--line); border-radius: 10px;
  padding: 12px;
}
#emp-card.hidden { display: none; }
#card-top { display: flex; gap: 10px; align-items: center; position: relative; }
#card-avatar { width: 48px; height: 48px; border-radius: 8px; border: 1px solid var(--line); image-rendering: pixelated; }
#card-name { font-size: 16px; font-weight: bold; }
#card-rank {
  display: inline-block; font-size: 10px; color: #0b0c10;
  border-radius: 4px; padding: 2px 6px; margin-left: 6px;
}
#card-role { color: var(--dim); font-size: 11px; margin-top: 3px; }
#card-close {
  position: absolute; top: -4px; right: -4px; padding: 2px 7px;
  background: transparent; border: none; color: var(--dim); font-size: 14px;
}
#card-level { color: var(--yellow); font-size: 12px; }
.xp-bar { background: #14151c; border-radius: 4px; height: 8px; margin: 4px 0 2px; overflow: hidden; }
.xp-bar div { height: 100%; background: var(--green); transition: width .3s; }
#card-xp-num { font-size: 10px; color: var(--dim); }

.card-sec { margin-top: 10px; }
.card-sec h5 { font-size: 10px; color: var(--dim); margin-bottom: 5px; letter-spacing: 1px; }
.stat-row { display: flex; align-items: center; gap: 6px; margin: 3px 0; font-size: 11px; }
.stat-row span { width: 76px; flex-shrink: 0; color: var(--dim); }
.stat-row b { width: 28px; text-align: right; font-size: 11px; }
.stat-bar { flex: 1; height: 7px; background: #14151c; border-radius: 3px; overflow: hidden; }
.stat-bar div { height: 100%; background: linear-gradient(90deg, var(--blue), var(--green)); }

.tag {
  display: inline-block; font-size: 10px; padding: 2px 7px; border-radius: 4px;
  background: #303446; margin: 0 3px 3px 0; color: #fff;
}
#card-status { color: var(--green); }
#card-salary { color: var(--yellow); }
.kv { display: flex; justify-content: space-between; font-size: 12px; margin: 3px 0; }
.kv span:first-child { color: var(--dim); }
.train-btn {
  width: 100%; margin-top: 12px; padding: 9px 0;
  background: #c43c4e; border-color: #c43c4e; color: #fff;
  font-size: 12px; border-radius: 8px;
}
.train-btn:hover { background: #d94a5d; }
.train-btn:disabled { opacity: .45; cursor: default; }
.persona-btn {
  width: 100%; margin-top: 7px; padding: 8px 0;
  background: #6b4ad1; border-color: #6b4ad1; color: #fff;
  font-size: 12px; border-radius: 8px;
}
.persona-btn:hover { background: #7d5ce0; }
.trait-chk {
  font-size: 11px; padding: 3px 8px; border: 1px solid var(--line);
  border-radius: 5px; cursor: pointer; user-select: none; color: var(--dim);
}
.trait-chk input { display: none; }
.trait-chk.on { background: #3d6bd9; color: #fff; border-color: #3d6bd9; }
.net-t {
  font-size: 10px; padding: 3px 8px; border: 1px solid var(--line);
  border-radius: 5px; cursor: pointer; background: var(--panel2); color: var(--dim);
}
.net-t.on { background: #3d6bd9; color: #fff; border-color: #3d6bd9; }
#card-note { color: var(--purple); font-size: 11px; margin-top: 4px; line-height: 1.5; }

#proj-panel { flex: 1; }
.proj-row {
  background: var(--panel2); border: 1px solid var(--line); border-radius: 8px;
  padding: 8px 10px; margin-bottom: 6px;
}
.proj-title { font-size: 12px; margin-bottom: 4px; }
.proj-meta { display: flex; align-items: center; gap: 6px; font-size: 10px; color: var(--dim); margin-bottom: 5px; }
.proj-bar { height: 7px; background: #14151c; border-radius: 3px; overflow: hidden; }
.proj-bar div { height: 100%; background: var(--purple); transition: width .3s; }
.stage-0 { background: #3d6bd9; } .stage-1 { background: #d94343; }
.stage-2 { background: #8d4ad9; } .stage-3 { background: #3da86a; }
.empty { color: var(--dim); font-size: 11px; padding: 8px; }

/* ---------- 건설 팔레트 ---------- */
#palette {
  background: var(--panel2); border: 1px solid var(--blue); border-radius: 10px;
  padding: 10px;
}
#palette.hidden { display: none; }
#palette h4 { font-size: 11px; color: var(--blue); margin-bottom: 8px; }
#palette-items, #palette-rooms { display: flex; flex-wrap: wrap; gap: 5px; }
#palette-items button, #palette-rooms button { font-size: 11px; padding: 5px 8px; }
#palette-items button.erase, #palette-rooms button.erase { border-color: var(--red); color: var(--red); }
#palette-items button.erase.on, #palette-rooms button.erase.on { background: var(--red); color: #0b0c10; }
#palette-rooms button { border-color: #3da86a; }
#palette-rooms button.on { background: #3da86a; color: #0b0c10; }
#palette .hint { margin-top: 8px; }
#palette-reset { margin-top: 8px; font-size: 11px; }
#btn-reset-game { margin-top: 4px; margin-left: 6px; font-size: 11px; color: var(--red); }

/* ---------- 모달 ---------- */
#modal-bg {
  position: fixed; inset: 0; background: rgba(5,6,10,0.7);
  display: flex; align-items: center; justify-content: center; z-index: 50;
}
#modal-bg.hidden { display: none; }
#modal {
  width: min(680px, 92vw); max-height: 82vh; overflow-y: auto;
  background: var(--panel); border: 2px solid var(--line); border-radius: 12px;
  padding: 16px 18px;
}
#modal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
#modal-title { font-size: 15px; color: var(--yellow); }
#modal-close { background: transparent; border: none; font-size: 16px; color: var(--dim); }
#modal-body h3 { font-size: 13px; margin: 14px 0 6px; }
#modal-body h3:first-child { margin-top: 0; }

.tbl { width: 100%; border-collapse: collapse; font-size: 12px; }
.tbl th { color: var(--dim); font-size: 10px; text-align: left; padding: 4px 6px; border-bottom: 1px solid var(--line); }
.tbl td { padding: 5px 6px; border-bottom: 1px solid #23242e; }
.emp-row { cursor: pointer; }
.emp-row:hover td { background: #23242e; }
.hint { color: var(--dim); font-size: 11.5px; line-height: 1.6; margin: 8px 0; }

.lc-CashCow { background: #3da86a; } .lc-Growth { background: #3d6bd9; }
.lc-New { background: #d9a23d; } .lc-Experimental { background: #8d4ad9; }

.report-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.kpi { background: var(--panel2); border: 1px solid var(--line); border-radius: 8px; padding: 10px; text-align: center; }
.kpi-n { font-size: 16px; color: var(--green); }
.kpi-l { font-size: 10px; color: var(--dim); margin-top: 4px; }

.fld { display: block; margin: 10px 0; font-size: 12px; color: var(--dim); }
.fld input[type=password], .fld input[type=text], .fld select {
  display: block; width: 100%; margin-top: 5px;
  background: var(--panel2); border: 1px solid var(--line); border-radius: 6px;
  color: var(--text); padding: 8px; font-family: inherit; font-size: 12px;
}
.fld.row { display: flex; align-items: center; gap: 8px; color: var(--text); }
.row-btns { display: flex; gap: 8px; margin-top: 12px; }

.proj-row.big .proj-meta { font-size: 12px; }
.proj-row.big b { margin-left: auto; color: var(--green); }

::-webkit-scrollbar { width: 8px; }
::-webkit-scrollbar-thumb { background: var(--line); border-radius: 4px; }
::-webkit-scrollbar-track { background: transparent; }

@media (max-width: 1000px) {
  #side { display: none; }
  body.side-open #side {
    display: flex; position: fixed; right: 8px; top: 100px; bottom: 8px;
    width: 300px; z-index: 40;
    border: 1px solid var(--line); border-radius: 10px;
    box-shadow: -6px 0 24px rgba(0,0,0,0.55);
  }
}

/* 하루 리포트 카드 */
.rep-list { margin-top: 12px; }
.rep-row {
  display: flex; justify-content: space-between; gap: 12px;
  padding: 7px 10px; margin-bottom: 5px;
  background: var(--panel2); border: 1px solid var(--line); border-radius: 8px;
  font-size: 12px;
}
.rep-row span { color: var(--dim); flex-shrink: 0; }
.rep-row b { text-align: right; }
.rep-row b { margin-left: auto; }

/* ---------- 모바일 반응형 ---------- */
@media (max-width: 760px) {
  body { font-size: 12px; }
  #topbar { padding: 6px 8px; gap: 5px; }
  #logo { font-size: 12px; margin-right: 2px; }
  .pill { padding: 4px 7px; gap: 4px; }
  .pill b { font-size: 11px; }
  .pill .ic { width: 18px; height: 18px; font-size: 10px; }
  .pill.hide-m { display: none; }
  #speed-ctrl { margin-left: 0; width: 100%; justify-content: flex-end; }
  #speed-ctrl button { padding: 4px 8px; font-size: 11px; }
  #game-area { padding: 5px; gap: 5px; }
  #view-tabs { flex-wrap: nowrap; overflow-x: auto; padding-bottom: 3px; -webkit-overflow-scrolling: touch; }
  #view-tabs button { flex-shrink: 0; font-size: 10px; padding: 5px 8px; }
  #bottom { height: auto; flex-direction: column; }
  #log-panel { height: 84px; }
  #menu { grid-template-columns: repeat(7, 1fr); gap: 4px; width: 100%; }
  #menu button { height: 44px; font-size: 9px; gap: 1px; }
  #menu button .mi { font-size: 15px; }
  body.side-open #side { top: 0; right: 0; bottom: 0; width: min(320px, 92vw); border-radius: 0; }
  #modal { width: 96vw; max-height: 88vh; padding: 12px; }
  .report-grid { grid-template-columns: repeat(2, 1fr); }
  .bubble { font-size: 10px; max-width: 150px; }
}

/* ONA 추천 카드 */
.rec-card { background: var(--panel2); border: 1px solid var(--line); border-radius: 8px; padding: 9px 11px; margin-bottom: 6px; }
.rec-head { font-size: 12px; }
.rec-card .hint { margin: 3px 0 0; font-size: 11px; }

/* 1:1 면담 창 */
.talk-btn { width: 100%; margin-top: 7px; padding: 9px 0; background: #1fa394; border-color: #1fa394; color: #fff; font-size: 12px; border-radius: 8px; }
.talk-btn:hover { background: #25b8a7; }
.iv-head { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 4px; font-size: 11px; color: var(--green); margin-bottom: 8px; }
.iv-log { height: 300px; overflow-y: auto; background: #14151c; border: 1px solid var(--line); border-radius: 10px; padding: 10px; }
.iv-msg { max-width: 78%; margin-bottom: 8px; font-size: 12px; }
.iv-msg b { display: block; font-size: 10px; color: var(--dim); margin-bottom: 2px; }
.iv-msg div { background: var(--panel2); border: 1px solid var(--line); border-radius: 10px; padding: 7px 10px; line-height: 1.5; }
.iv-msg.me { margin-left: auto; text-align: right; }
.iv-msg.me div { background: #1f3a5c; border-color: #2f5a8c; text-align: left; }
.iv-msg.coach { max-width: 100%; }
.iv-msg.coach div { background: #2a2440; border-color: #6b4ad1; }
