:root {
  --bg: #1d1a22;
  --panel: #2b2733;
  --text: #f1ece4;
  --muted: #a39cae;
  --accent: #ffe27a;
  --danger: #ff7a7a;
}
* { box-sizing: border-box; }
html { height: 100%; }
/* 화면 높이에 딱 맞춘다: 남는 높이는 게임 화면(#stageArea)이 다 가져간다 */
body { margin: 0; height: 100vh; height: 100dvh; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: "Galmuri11", "DungGeunMo", system-ui, sans-serif;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 12px 16px;
  gap: 10px;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
}
header, #msg {
  width: 100%;
  max-width: 720px;
}
header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 4px 12px;
}
h1 { font-size: 18px; margin: 0; }
#hud { color: var(--muted); font-size: 14px; line-height: 1.5; }
#hud b { color: var(--accent); font-weight: normal; }
/* 체력 막대: 초록 → 절반 아래 노랑 → 위험하면 빨강. 숫자는 막대 위에 겹쳐 쓴다 */
#hud .hpbar {
  position: relative;
  display: inline-block;
  width: 96px;
  height: 16px;
  vertical-align: -3px;
  background: #3a3544;
  border-radius: 4px;
  overflow: hidden;
}
#hpFill { position: absolute; inset: 0 auto 0 0; width: 100%; background: #4fa878; transition: width 0.15s; }
#hud .hpbar.mid #hpFill { background: #c9981e; }
#hud .hpbar.low #hpFill { background: #d9434a; }
#hud .hpbar b {
  position: relative;
  display: block;
  text-align: center;
  font-size: 12px;
  line-height: 16px;
  color: #fff;
  text-shadow: 0 1px 0 rgba(0, 0, 0, 0.6);
}
/* 시계: 21시까진 초록, 23시까진 노랑, 그 뒤 빨강. 00:00 이면 멈춰서 흔들린다 */
#hud #clock.ok { color: #7fd6a8; }
#hud #clock.late { color: var(--danger); }
#hud #clock.midnight { color: var(--danger); display: inline-block; animation: midnight 0.5s ease-in-out infinite; }
@keyframes midnight {
  0%, 100% { transform: rotate(0); }
  25% { transform: rotate(-6deg); }
  75% { transform: rotate(6deg); }
}
@media (prefers-reduced-motion: reduce) {
  #hud #clock.midnight { animation: none; }
}
#stageArea {
  flex: 1 1 0;
  min-height: 0;
  width: 100%;
  max-width: 720px;
  display: flex;
  justify-content: center;
  align-items: flex-start;
}
/* 게임 화면 크기는 js/render.js 의 fitCanvas 가 정한다 (가로 15칸 고정, 세로는 들어가는 만큼) */
#stage {
  position: relative;
  flex: none;
}
#game {
  display: block;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  background: #000;
  border: 2px solid var(--panel);
}
/* 아래쪽: 사장님은 출구 옆이라 화면 위쪽에 자주 서서, 위에 두면 머리를 가린다 */
#bossbar {
  position: absolute;
  bottom: 8px;
  left: 50%;
  transform: translateX(-50%);
  width: min(80%, 360px);
  display: none;
  flex-direction: column;
  gap: 3px;
  padding: 5px 8px;
  background: rgba(20, 18, 26, 0.8);
  border-radius: 6px;
  font-size: 12px;
  text-align: center;
  pointer-events: none;
}
#bossbar.show { display: flex; }
#bossbar #bossbonus { color: var(--danger); }
#bossbar .track { height: 6px; background: #3a3544; border-radius: 3px; overflow: hidden; }
#bossfill { height: 100%; width: 100%; background: #e6b422; transition: width 0.15s; }
#overlay {
  position: absolute;
  inset: 0;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  background: rgba(20, 18, 26, 0.85);
  text-align: center;
  padding: 0 16px;
}
#overlay.show { display: flex; }
#overlay h2 { margin: 0; font-size: 28px; color: var(--accent); }
#overlay.lose h2 { color: var(--danger); }
#overlay p { margin: 0; color: var(--text); }
#overlay #best { color: var(--muted); font-size: 14px; }
#overlay #seed { color: var(--muted); font-size: 12px; }
/* 계단에서 고르는 강화 카드 */
#perk {
  position: absolute;
  inset: 0;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: safe center;
  gap: 10px;
  padding: 8px 12px;
  overflow-y: auto;
  background: rgba(20, 18, 26, 0.88);
  text-align: center;
}
#perk.show { display: flex; }
#perk h2 { margin: 0; font-size: 20px; color: var(--accent); }
#perk p { margin: 0; font-size: 12px; color: var(--muted); }
#perk .cards { display: flex; gap: 8px; width: 100%; max-width: 440px; }
#perk .cards button {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 12px 8px;
  background: var(--panel);
  color: var(--text);
  border: 2px solid #4a4458;
  border-radius: 10px;
  font-family: inherit;
  font-size: 13px;
  line-height: 1.4;
}
#perk .cards button:active { border-color: var(--accent); }
#perk .cards b { font-size: 15px; color: var(--accent); font-weight: normal; }
#perk .cards .key { color: var(--muted); font-size: 11px; }
#perks { color: var(--muted); font-size: 12px; margin: 0; }
/* 점수표가 붙으면 좁은 폰 화면에 맞게 촘촘하게. 넘치면 위가 잘리지 않고 스크롤 */
#overlay { overflow-y: auto; justify-content: safe center; }
#overlay.scored { gap: 4px; padding: 8px 16px; }
#overlay.scored h2 { font-size: 20px; }
#overlay.scored #result { font-size: 13px; }
#overlay.scored button { margin-top: 2px; padding: 8px 18px; }
#score { display: none; flex-direction: column; align-items: center; gap: 4px; }
#score.show { display: flex; }
#score .total { font-size: 22px; color: var(--accent); line-height: 1.1; }
#score .total small { font-size: 14px; color: var(--muted); }
#score dl {
  display: grid;
  grid-template-columns: auto auto;
  gap: 0 14px;
  margin: 0;
  font-size: 12px;
  line-height: 1.35;
}
#score dt { color: var(--muted); text-align: left; }
#score dd { margin: 0; text-align: right; }
#score dd.minus { color: var(--danger); }
#score .new { color: #7fd6a8; font-size: 12px; }
#overlay button {
  margin-top: 6px;
  padding: 10px 20px;
  font-size: 16px;
  font-family: inherit;
  background: var(--accent);
  color: #1d1a22;
  border: 0;
  border-radius: 8px;
}
/* 시작화면 — 화면 전체를 덮는다 (게임 화면 · 아이템 버튼 · 방향 패드까지 가린다. 창보다는 아래)
   2026-10-11: 게임 화면 틀 안에만 있어서 아래에 아이템 버튼과 패드가 비쳐 보였다 */
#title {
  position: fixed;
  inset: 0;
  z-index: 5;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: safe center;
  gap: 10px;
  overflow-y: auto;
  background: var(--bg);
  text-align: center;
  padding: 16px;
}
#title.show { display: flex; }
#titleName { margin: 0 0 6px; font-size: 26px; color: var(--accent); font-weight: normal; }
#titleArt {
  width: min(88%, 420px, 60vh); /* 가로로 누운 화면에서는 높이에 맞춰 줄인다 */
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  border: 2px solid var(--panel);
}
#title p { margin: 0; font-size: 15px; }
#titleBest { color: var(--muted); font-size: 13px !important; min-height: 1em; }
/* 첫 줄: 퇴근하기(크게) + 상점. 나머지 넷은 그 아래 한 줄에 */
#title .buttons { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-top: 10px; width: min(100%, 400px); }
#title #startBtn { grid-column: 1 / 4; }
#title #shopBtn { font-size: 16px; }
#title button.sub { padding: 12px 2px; font-size: 13px; white-space: nowrap; }
/* 시작 연출 중엔 그림과 한 줄만 남긴다 (자리는 그대로 둬서 그림이 움직이지 않게) */
#title.leaving .buttons, #title.leaving #titleBest { visibility: hidden; }
#title button {
  padding: 16px;
  font-size: 18px;
  font-family: inherit;
  background: var(--accent);
  color: #1d1a22;
  border: 0;
  border-radius: 8px;
  cursor: pointer;
}
#title button.sub { background: var(--panel); color: var(--text); }
/* 창 (게임 방법 · 탄 고르기 · 환경설정) — 폰에서도 읽기 편하게 화면 전체를 덮는다 */
.dialog {
  position: fixed;
  inset: 0;
  display: none;
  justify-content: center;
  align-items: flex-start;
  padding: 16px;
  background: rgba(20, 18, 26, 0.9);
  z-index: 10;
}
.dialog.show { display: flex; }
.dialog .panel {
  width: 100%;
  max-width: 560px;
  max-height: 100%;
  overflow-y: auto;
  background: var(--panel);
  border-radius: 10px;
  padding: 0 16px 16px;
  font-size: 14px;
  line-height: 1.5;
}
.dialog .bar {
  position: sticky;
  top: 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 0 8px;
  background: var(--panel);
}
.dialog h2 { margin: 0; font-size: 18px; color: var(--accent); }
.dialog h3 { margin: 14px 0 6px; font-size: 15px; color: var(--accent); }
.dialog p { margin: 0; }
.dialog button {
  padding: 6px 14px;
  font-size: 14px;
  font-family: inherit;
  background: var(--bg);
  color: var(--text);
  border: 0;
  border-radius: 6px;
  cursor: pointer;
}
.dialog ul { margin: 0; padding: 0; list-style: none; }
.dialog .howto li { display: grid; grid-template-columns: 4.5em 1fr; }
.dialog .howto li b { color: var(--muted); font-weight: normal; }
.dialog .cards { display: flex; flex-direction: column; gap: 8px; }
.dialog .cards li {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 8px;
  background: var(--bg);
  border-radius: 8px;
}
.dialog .cards img {
  flex: none;
  width: 48px;
  height: 48px;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}
.dialog .cards .name { display: flex; flex-wrap: wrap; gap: 4px 8px; align-items: baseline; }
.dialog .cards .name b { font-weight: normal; }
.dialog .tag {
  font-size: 12px;
  padding: 0 6px;
  border-radius: 4px;
  background: #4a4458;
  color: var(--accent);
}
.dialog .tag.where { color: var(--muted); background: transparent; padding: 0; }
.dialog .cards .desc { color: var(--muted); }
/* 탄 고르기 */
.dialog .stages { display: flex; flex-direction: column; gap: 8px; margin-top: 4px; }
.dialog .stages button {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  width: 100%;
  padding: 12px;
  text-align: left;
  border: 2px solid #4a4458;
  line-height: 1.4;
}
.dialog .stages button:not(:disabled):hover,
.dialog .stages button:not(:disabled):focus-visible { border-color: var(--accent); }
.dialog .stages button:disabled { cursor: default; opacity: 0.55; }
.dialog .stages b { font-size: 16px; color: var(--accent); font-weight: normal; }
.dialog .stages span { color: var(--muted); font-size: 13px; }
.dialog .stages b span { color: inherit; font-size: inherit; }
/* 환경설정 */
.dialog .setting { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid #3a3544; }
.dialog .setting label { flex: none; width: 6em; }
.dialog .setting input[type=range] { flex: 1; accent-color: var(--accent); }
.dialog .setting input[type=checkbox] { flex: none; width: 20px; height: 20px; accent-color: var(--accent); }
.dialog .setting output { width: 3em; text-align: right; color: var(--muted); }
/* 게임 방법 */
.dialog .rules { display: flex; flex-direction: column; gap: 8px; margin-top: 4px; }
.dialog .rules li { padding-left: 1em; text-indent: -1em; }
.dialog .rules li::before { content: '· '; color: var(--accent); }
.dialog .rules b { color: var(--accent); font-weight: normal; }
/* 도감 */
.dialog h3 .count { color: var(--muted); font-size: 13px; }
.dialog .cards li.unknown { display: flex; gap: 10px; align-items: flex-start; padding: 8px; background: var(--bg); border-radius: 8px; }
.dialog .cards li.unknown .name b { color: var(--muted); }
.dialog .cards .seen { color: #7fd6a8; font-size: 12px; }
.dialog .diary { display: flex; flex-direction: column; gap: 8px; margin-top: 8px; }
.dialog .diary li button { display: block; width: 100%; padding: 10px 12px; text-align: left; background: #fbf6e4; color: #2d3f7a; border-radius: 4px; font-size: 14px; }
.dialog .diary li b { display: block; margin-bottom: 2px; color: #b04a5a; font-size: 15px; font-weight: normal; }
.dialog .diary li.unknown button { background: var(--bg); color: #5d5768; cursor: default; }
.dialog .diary li.unknown b { color: var(--muted); }
.dialog .tabs .count { font-size: 12px; opacity: 0.8; }
.dialog .tab[hidden] { display: none; }
/* 일기 쪽지 — 크림색 줄 종이 + 왼쪽 빨간 여백선 + 접힌 귀퉁이. 글 줄 높이를 종이 줄 간격(28px)에 맞춘다
   (그림자는 기울인 바깥 .sheet 에 — 안쪽 .paper 는 귀퉁이를 잘라 내서 그림자까지 잘린다) */
#diary {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 16px;
  background: rgba(15, 13, 20, 0.72);
}
#diary.show { display: flex; }
#diary .sheet {
  width: min(100%, 340px);
  transform: rotate(-1.5deg);
  filter: drop-shadow(0 6px 14px rgba(0, 0, 0, 0.5));
  animation: diaryIn 0.25s ease-out;
}
#diary .paper {
  position: relative;
  padding: 28px 18px 28px 46px;
  color: #2d3f7a;
  background:
    linear-gradient(to right, transparent 34px, #e8a0a8 34px, #e8a0a8 35px, transparent 35px),
    repeating-linear-gradient(to bottom, #fbf6e4 0, #fbf6e4 27px, #c9d6e6 27px, #c9d6e6 28px);
  clip-path: polygon(0 0, 100% 0, 100% calc(100% - 24px), calc(100% - 24px) 100%, 0 100%);
}
#diary .paper::after {
  content: '';
  position: absolute;
  right: 0;
  bottom: 0;
  width: 24px;
  height: 24px;
  background: linear-gradient(to bottom right, #e3d7b4 50%, transparent 50%);
}
#diary h2 { margin: 0; font-size: 14px; line-height: 28px; color: #b04a5a; font-weight: normal; }
#diary p { margin: 0; font-size: 16px; line-height: 28px; white-space: pre-wrap; word-break: keep-all; }
#diary .hint { color: var(--muted); font-size: 12px; line-height: normal; }
@keyframes diaryIn {
  from { opacity: 0; transform: translateY(12px) rotate(-1.5deg); }
}
@media (prefers-reduced-motion: reduce) {
  #diary .sheet { animation: none; }
}
.dialog .note { color: var(--muted); font-size: 12px; margin-top: 8px; }
/* 상점 */
.dialog .wallet { font-size: 16px; }
.dialog .wallet b { color: var(--accent); font-weight: normal; }
#shopList li { align-items: center; }
#shopList li > div { flex: 1; }
#shopList li.wearing { outline: 2px solid var(--accent); }
/* 입기 · 사기 · 입는 중: 글자 수가 달라도 같은 너비 (옆 설명 글의 줄바꿈이 옷마다 달라지지 않게) */
#shopList button { flex: none; width: 5.5em; padding: 6px 0; white-space: nowrap; background: var(--panel); }
#shopList button.buy { background: var(--accent); color: #1d1a22; }
#shopList button:disabled { background: transparent; color: var(--muted); cursor: default; }
#shopList button.buy:disabled { background: var(--panel); color: #5d5768; }
/* 결과 화면의 월급 한 줄 */
#overlay #wage { color: #7fd6a8; font-size: 12px; }
/* 기록 */
.dialog .tabs { display: flex; gap: 6px; margin: 4px 0 12px; }
.dialog .tabs:empty { display: none; }
.dialog .tabs button { flex: 1; color: var(--muted); }
.dialog .tabs button[aria-pressed="true"] { background: var(--accent); color: #1d1a22; }
.dialog .stats { display: grid; grid-template-columns: auto 1fr; gap: 6px 16px; margin: 4px 0 0; }
.dialog .stats dt { color: var(--muted); }
.dialog .stats dd { margin: 0; text-align: right; color: var(--accent); }
.dialog .stats dd.none { color: #5d5768; }
.dialog .recent { display: flex; flex-direction: column; gap: 6px; }
.dialog .recent li { display: flex; flex-wrap: wrap; gap: 2px 10px; padding: 8px; background: var(--bg); border-radius: 8px; }
.dialog .recent li.none { color: var(--muted); }
.dialog .recent .day { color: var(--muted); min-width: 3em; }
.dialog .recent .win { color: #7fd6a8; }
.dialog .recent .lose { color: var(--danger); }
.dialog .recent .detail { color: var(--muted); margin-left: auto; }
/* 높이를 고정한다: 메시지 줄 수가 바뀔 때마다 게임 화면 크기가 출렁이지 않게. 넘치면 스크롤 */
#msg {
  margin: 0;
  height: 2.8em;
  line-height: 1.4;
  overflow-y: auto;
  font-size: 14px;
  color: var(--text);
}
/* 폰: 게임 중엔 제목을 빼고 그 자리를 게임 화면에 준다 (제목은 시작화면에 있다). 글이 좁아 줄이 더 필요하다 */
@media (max-width: 480px) {
  body { padding: 8px 12px; gap: 8px; }
  h1 { display: none; }
  #hud { width: 100%; min-height: 3em; }
  #msg { height: 4.2em; }
}
#items {
  width: 100%;
  max-width: 720px;
  display: grid;
  grid-auto-flow: column;   /* 아이템 종류 수만큼 한 줄에 똑같은 너비로 */
  grid-auto-columns: 1fr;
  gap: 6px;
}
#items button {
  background: var(--panel);
  color: var(--text);
  border: 0;
  border-radius: 8px;
  padding: 8px 4px;
  font-size: 14px;
  font-family: inherit;
}
#items button:disabled { color: #5d5768; }
#items button:not(:disabled):active { background: #4a4458; }
#items .key { color: var(--muted); font-size: 12px; }
/* 회식에 붙잡혔을 때 쓸 수 있는 탈출 아이템: 눌러 보라고 깜빡인다 */
#items button.hint {
  color: #1d1a22;
  background: var(--accent);
  animation: hint 0.8s ease-in-out infinite alternate;
}
#items button.hint .key { color: #4a4458; }
@keyframes hint {
  from { box-shadow: 0 0 0 0 rgba(255, 226, 122, 0.9); }
  to   { box-shadow: 0 0 0 5px rgba(255, 226, 122, 0); }
}
/* 멘탈이 낮으면 화면 가장자리가 붉게 맥박친다 */
#stage::after {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0;
  box-shadow: inset 0 0 40px 12px rgba(217, 67, 74, 0.75);
  transition: opacity 0.3s;
}
#stage.danger::after { animation: danger 1s ease-in-out infinite alternate; }
@keyframes danger {
  from { opacity: 0.35; }
  to   { opacity: 1; }
}
@media (prefers-reduced-motion: reduce) {
  #items button.hint { animation: none; }
  #stage.danger::after { animation: none; opacity: 0.7; }
}
#status b { color: #7fd6a8; font-weight: normal; }
#status b.bad { color: var(--danger); }
/* 방향키는 화면 맨 아래로 — 엄지가 닿는 자리 */
#pad {
  flex: none;
  padding-bottom: env(safe-area-inset-bottom);
  display: grid;
  grid-template-columns: repeat(3, 64px);
  grid-template-rows: repeat(3, 64px);
  gap: 6px;
}
#pad button {
  background: var(--panel);
  color: var(--text);
  border: 0;
  border-radius: 10px;
  font-size: 24px;
  font-family: inherit;
}
#pad button:active { background: #4a4458; }
#pad button { -webkit-touch-callout: none; } /* iOS 길게 누르기 메뉴 막기 */
#pad .up    { grid-column: 2; grid-row: 1; }
#pad .left  { grid-column: 1; grid-row: 2; }
#pad .throw { grid-column: 2; grid-row: 2; font-size: 14px; }
#pad .throw:disabled { color: #5d5768; }
#pad .right { grid-column: 3; grid-row: 2; }
#pad .down  { grid-column: 2; grid-row: 3; }
/* 키보드가 있는 환경에서는 패드를 숨긴다 */
@media (hover: hover) and (pointer: fine) {
  #pad { display: none; }
}

/* 민랩노트 허브·개인정보처리방침 링크 */
.mln-links{text-align:center;font-size:12px;line-height:1.6;margin-top:14px;opacity:.75}
.mln-links a{color:inherit;text-decoration:underline;text-underline-offset:3px}
