/* 존버타임 — 사무실 톤. 모바일 우선. */
:root {
  --bg: #14161b;
  --bg2: #1c1f27;
  --card: #f4f1ea;      /* 서류 종이 */
  --card-ink: #23262e;
  --line: #2c303a;
  --accent: #ffcf4a;    /* 형광펜 노랑 */
  --mental: #59c3ff;
  --boss: #ff6b6b;
  --peer: #7be0a4;
  --danger: #ff4d4d;
  --muted: #8a90a0;
  --paper-shadow: 0 12px 30px rgba(0,0,0,.45);
  font-size: 16px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: #eceef4;
  font-family: -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Pretendard", "Malgun Gothic", sans-serif;
  overflow: hidden;
  overscroll-behavior: none;
  user-select: none;
}

#app {
  position: relative;
  width: 100%;
  max-width: 480px;
  height: 100dvh;
  margin: 0 auto;
  background: linear-gradient(180deg, var(--bg2), var(--bg));
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.screen { display: none; position: absolute; inset: 0; flex-direction: column; }
.screen.is-active { display: flex; }

.btn {
  border: 0; border-radius: 14px; padding: 15px 22px;
  font-size: 1.05rem; font-weight: 700; cursor: pointer;
  transition: transform .08s ease, opacity .15s ease;
  font-family: inherit;
}
.btn:active { transform: scale(.96); }
.btn-primary { background: var(--accent); color: #1a1a1a; }
.btn-ghost { background: transparent; color: var(--muted); border: 1px solid var(--line); }

/* ---------- 타이틀 ---------- */
.title-wrap { margin: auto; text-align: center; padding: 32px 26px; width: 100%; }
.lanyard {
  display: inline-block; background: #2b2f3a; color: var(--muted);
  font-size: .7rem; letter-spacing: .3em; padding: 5px 16px; border-radius: 0 0 8px 8px;
  margin-bottom: 26px;
}
.title-art { display: flex; gap: 4px; justify-content: center; flex-wrap: wrap; margin-bottom: 20px; }
.ta-face {
  width: 34px; height: 34px; border-radius: 8px; overflow: hidden;
  box-shadow: 0 0 0 1.5px rgba(255,255,255,.1); transition: transform .2s;
}
.ta-face:hover { transform: translateY(-3px); }
.ta-face .avatar-cv { width: 100%; height: 100%; display: block; image-rendering: pixelated; }
.game-logo {
  font-size: 3.2rem; font-weight: 900; margin: 0; letter-spacing: -.03em;
  background: linear-gradient(180deg, #fff, var(--accent)); -webkit-background-clip: text;
  background-clip: text; color: transparent;
}
.game-sub { color: var(--muted); margin: 10px 0 34px; font-size: .95rem; }
.title-role { margin-bottom: 34px; }
.role-badge {
  display: inline-block; background: #23262e; border: 1px solid var(--line);
  padding: 6px 14px; border-radius: 999px; font-size: .82rem; color: #cfd3dd;
}
.role-line { color: var(--muted); font-size: .82rem; margin: 10px 0 0; }
#btn-start { width: 100%; max-width: 300px; }
.title-streak { color: var(--muted); font-size: .78rem; margin-top: 18px; min-height: 1em; }

/* ---------- HUD ---------- */
.hud { padding: 14px 18px 8px; }
.hud-top { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 12px; position: relative; }
.hud-left { display: flex; align-items: center; gap: 10px; }
.hud-home {
  border: 1px solid var(--line); background: var(--bg2); color: var(--muted);
  font-family: inherit; font-size: .82rem; font-weight: 800; line-height: 1;
  width: 26px; height: 26px; border-radius: 8px; cursor: pointer; padding: 0;
  transition: all .12s;
}
.hud-home:active { transform: scale(.92); }
.hud-home.arm { width: auto; padding: 0 10px; background: var(--danger); color: #fff; border-color: var(--danger); }
.day-label { font-weight: 800; letter-spacing: .04em; font-size: .95rem; }
.money-wrap { position: relative; }
.money { font-variant-numeric: tabular-nums; font-weight: 800; color: var(--accent); display: inline-block; }
.money.neg { color: var(--danger); }
.money.bump { animation: bump .4s cubic-bezier(.3,1.6,.5,1); }
.money-float {
  position: absolute; right: 0; top: 100%; font-size: .82rem; font-weight: 800;
  white-space: nowrap; pointer-events: none; animation: moneyFloat 1.1s ease forwards;
}
.money-float.up { color: var(--accent); }
.money-float.down { color: var(--danger); }
@keyframes moneyFloat { 0% { opacity: 0; transform: translateY(-2px); } 20% { opacity: 1; } 100% { opacity: 0; transform: translateY(14px); } }

.gauges { display: flex; flex-direction: column; gap: 8px; }
.gauge { display: flex; align-items: center; gap: 9px; position: relative; }
.gauge-name { width: 3.6em; font-size: .72rem; color: var(--muted); text-align: right; flex-shrink: 0; }
.gauge-track { flex: 1; height: 10px; background: #262a34; border-radius: 6px; overflow: hidden; position: relative; }
.gauge-fill { height: 100%; border-radius: 6px; transform-origin: left center; transition: width .45s cubic-bezier(.3,.9,.4,1), background .2s; }
.gauge.mental .gauge-fill { background: var(--mental); }
.gauge.boss .gauge-fill { background: var(--boss); }
.gauge.peer .gauge-fill { background: var(--peer); }
.gauge.danger .gauge-fill { background: var(--danger) !important; animation: pulse .6s infinite; }
.gauge-fill.bump { animation: fillBump .45s ease; }
@keyframes pulse { 50% { opacity: .5; } }
@keyframes fillBump { 0% { filter: brightness(2.4); transform: scaleY(1.8); } 100% { filter: none; transform: scaleY(1); } }
@keyframes bump { 0% { transform: scale(1); } 45% { transform: scale(1.35); } 100% { transform: scale(1); } }
/* 게이지 위로 튀는 델타 숫자 */
.float-delta {
  position: absolute; right: 2px; top: -4px; font-size: 1rem; font-weight: 900;
  pointer-events: none; text-shadow: 0 1px 3px rgba(0,0,0,.5);
  animation: floatUp 1s cubic-bezier(.2,.7,.3,1) forwards;
}
.float-delta.up { color: var(--peer); }
.float-delta.down { color: var(--danger); }
@keyframes floatUp { 0% { opacity: 0; transform: translateY(6px) scale(.6); } 25% { opacity: 1; transform: translateY(-6px) scale(1.25); } 100% { opacity: 0; transform: translateY(-24px) scale(1); } }

/* 화면 흔들림 */
.shake { animation: shake .32s; }
.shake-hard { animation: shake .42s; }
@keyframes shake { 10%,90% { transform: translateX(-2px); } 30%,70% { transform: translateX(4px); } 50% { transform: translateX(-5px); } }

/* ---------- 온보딩 브리핑 ---------- */
.intro-wrap { margin: auto; padding: 30px 26px; width: 100%; max-width: 440px; }
.intro-kicker { color: var(--accent); font-size: .76rem; font-weight: 800; letter-spacing: .18em; margin: 0 0 6px; }
.intro-title { font-size: 1.7rem; font-weight: 900; margin: 0 0 18px; letter-spacing: -.02em; }
.intro-block { display: flex; flex-direction: column; gap: 11px; margin-bottom: 22px; }
.intro-block p { margin: 0; font-size: .96rem; line-height: 1.6; color: #d8dbe4; }
.intro-block b { color: #fff; }
.intro-sub { font-size: .9rem; color: var(--muted); margin: 0 0 12px; }
.intro-sub b { color: var(--accent); }
.intro-gauges { list-style: none; padding: 0; margin: 0 0 22px; display: flex; flex-direction: column; gap: 10px; }
.intro-gauges li { display: flex; align-items: center; gap: 12px; font-size: .86rem; color: #cfd3dd; }
.gtag { flex-shrink: 0; width: 6.2em; font-weight: 800; padding: 5px 0; border-radius: 8px; text-align: center; font-size: .8rem; }
.gtag.mental { background: rgba(89,195,255,.16); color: var(--mental); }
.gtag.boss { background: rgba(255,107,107,.16); color: var(--boss); }
.gtag.peer { background: rgba(123,224,164,.16); color: var(--peer); }
.intro-rule { font-size: .92rem; font-weight: 700; color: #eceef4; margin: 0 0 26px; line-height: 1.5; }
#btn-intro-go { width: 100%; }

/* ---------- 부서 선택 ---------- */
.role-wrap { margin: auto; padding: 26px 22px; width: 100%; max-width: 460px; }
.role-hint { color: var(--muted); font-size: .86rem; margin: 4px 0 18px; }
.role-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.role-card {
  display: flex; align-items: center; gap: 10px; text-align: left;
  background: var(--bg2); border: 1px solid var(--line); border-radius: 14px;
  padding: 12px; font-family: inherit; color: #eceef4; cursor: pointer; position: relative;
  transition: transform .08s, border-color .12s;
}
.role-card:active { transform: scale(.97); }
.role-card:not(.locked):active { border-color: var(--accent); }
.role-card.locked { opacity: .5; cursor: default; }
.role-ava { width: 40px; height: 40px; flex-shrink: 0; border-radius: 9px; overflow: hidden; box-shadow: 0 0 0 2px rgba(0,0,0,.15); }
.role-ava .avatar-cv { width: 100%; height: 100%; display: block; image-rendering: pixelated; }
.role-meta { min-width: 0; }
.role-name { font-weight: 800; font-size: .98rem; }
.role-desc { font-size: .72rem; color: var(--muted); margin-top: 2px; line-height: 1.3; }
.role-lock {
  position: absolute; top: 8px; right: 8px; font-size: .62rem; font-weight: 700;
  background: #33384a; color: #9aa2b6; padding: 2px 7px; border-radius: 999px;
}
.wallet-line { font-size: .84rem; color: #eceef4; margin: -8px 0 14px; }
.wallet-line b { color: var(--gold, #ffcf4a); font-weight: 800; }
.wallet-hint { color: var(--muted); font-size: .74rem; }
.role-card.forsale { border-style: dashed; }
.role-card.forsale .role-ava { filter: grayscale(.7) brightness(.75); }
.role-price {
  position: absolute; top: 8px; right: 8px; font-size: .62rem; font-weight: 800;
  background: rgba(255,207,74,.14); color: #ffcf4a; padding: 2px 7px; border-radius: 999px;
  transition: background .12s, color .12s;
}
.role-price.no { background: rgba(255,107,107,.16); color: #ff6b6b; }
.wallet-note { font-size: .82rem; font-weight: 700; color: #ffcf4a; margin: 2px 0 10px; }

/* ---------- 카드 (고정 레이아웃 — 카드/버튼 위치 안 흔들림) ---------- */
.card-stage {
  flex: 1; position: relative; display: flex; align-items: stretch;
  padding: 6px 20px 4px; overflow: hidden; min-height: 0;
}
.card {
  position: relative; width: 100%; max-width: 400px; margin: 0 auto;
  flex: 1; min-height: 0;
  background: var(--card); color: var(--card-ink); border-radius: 20px;
  box-shadow: var(--paper-shadow); padding: 16px 22px 18px;
  display: flex; flex-direction: column; overflow: hidden;
}
.card.dark { background: #10131a; color: #e8eaf0; } /* 새벽 슬랙 연출 */
.card-scene {
  flex: 0 0 auto; display: block; width: calc(100% + 44px); margin: -16px -22px 12px;
  aspect-ratio: 84 / 48; max-height: 44%; image-rendering: pixelated;
  border-radius: 20px 20px 0 0; box-shadow: inset 0 -2px 0 rgba(0,0,0,.15);
}
.card-head { display: flex; justify-content: flex-start; min-height: 1.4em; margin-bottom: 10px; }
.scene-chip {
  display: inline-block; background: #23262e; color: #cfd3dd;
  font-size: .72rem; font-weight: 700; padding: 4px 11px; border-radius: 999px;
}
.card.dark .scene-chip { background: rgba(255,255,255,.12); color: var(--accent); }

.speaker-row { display: flex; align-items: center; gap: 11px; margin-bottom: 16px; }
.avatar {
  width: 46px; height: 46px; flex-shrink: 0; border-radius: 10px; overflow: hidden;
  display: block; box-shadow: 0 0 0 2px rgba(0,0,0,.12);
}
.avatar.tone-up   { box-shadow: 0 0 0 2px #d98c4a; }
.avatar.tone-peer { box-shadow: 0 0 0 2px #d15b91; }
.avatar.tone-side { box-shadow: 0 0 0 2px #4a7fd9; }
.avatar-cv { width: 100%; height: 100%; display: block; image-rendering: pixelated; }
.speaker-name { font-size: .92rem; font-weight: 800; color: var(--card-ink); }
.card.dark .speaker-name { color: #e8eaf0; }
.speaker-rel { font-size: .72rem; font-weight: 700; margin-top: 2px; display: inline-block; }
.speaker-rel.tone-up   { color: #c0651a; }
.speaker-rel.tone-peer { color: #b8306e; }
.speaker-rel.tone-side { color: #3a63b8; }

.card-text { font-size: 1.16rem; line-height: 1.62; font-weight: 600; flex: 1; min-height: 0; overflow: auto; display: flex; flex-direction: column; justify-content: center; }
.card-text.narration { font-style: italic; color: #55504a; font-weight: 500; }
.card.dark .card-text.narration { color: #aeb4c2; }
.result-text { font-size: 1.08rem; line-height: 1.6; font-weight: 600; }
.result-deltas { margin-top: 18px; display: flex; flex-wrap: wrap; gap: 7px; }
.dchip {
  font-size: .82rem; font-weight: 800; padding: 4px 10px; border-radius: 999px;
  animation: chipPop .3s cubic-bezier(.3,1.6,.5,1) both;
}
.dchip.up { background: rgba(52,150,90,.16); color: #2e8b57; }
.dchip.down { background: rgba(210,60,60,.16); color: #c0392b; }
.card.dark .dchip.up { background: rgba(123,224,164,.18); color: var(--peer); }
.card.dark .dchip.down { background: rgba(255,107,107,.18); color: #ff8f8f; }
.dchip:nth-child(2) { animation-delay: .06s; }
.dchip:nth-child(3) { animation-delay: .12s; }
.dchip:nth-child(4) { animation-delay: .18s; }
@keyframes chipPop { from { opacity: 0; transform: scale(.5) translateY(6px); } }
.card.flip .card-text { animation: flipIn .28s ease; }
@keyframes flipIn { from { transform: rotateX(-12deg); opacity: 0; } }

/* ---------- 선택 버튼 (고정 높이 슬롯 — 선택→결과 넘어가도 자리 안 튐) ---------- */
.choice-zone {
  height: 130px; flex-shrink: 0; padding: 8px 20px 6px;
  display: flex; flex-direction: column; gap: 10px; justify-content: flex-end;
}
.choice-btn {
  width: 100%; height: 54px; flex: 0 0 54px; border-radius: 14px; padding: 0 18px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.05rem; font-weight: 800; font-family: inherit; cursor: pointer;
  background: var(--bg2); color: #eceef4; border: 1px solid var(--line);
  transition: transform .08s ease, border-color .12s, background .12s;
  text-align: center;
}
.choice-btn:active { transform: scale(.98); border-color: var(--accent); }
.choice-btn:first-child { border-left: 3px solid var(--boss); }
.choice-zone:not(.result-mode) .choice-btn:last-child { border-left: 3px solid var(--peer); }
.next-btn { background: var(--accent); color: #1a1a1a; border: 0; }

.run-progress { padding: 10px 22px 22px; }
.progress-bar { height: 5px; background: #262a34; border-radius: 4px; overflow: hidden; }
.progress-fill { height: 100%; width: 0; background: var(--accent); border-radius: 4px; transition: width .3s; }
.progress-text { display: block; text-align: center; color: var(--muted); font-size: .72rem; margin-top: 7px; }

/* ---------- 미니게임 ---------- */
.mg-root { flex: 1; display: flex; flex-direction: column; padding: 20px; }
.mg-head { text-align: center; margin-bottom: 8px; }
.mg-title { font-size: 1.3rem; font-weight: 900; }
.mg-desc { color: var(--muted); font-size: .82rem; margin-top: 4px; }
.mg-timer { height: 6px; background: #262a34; border-radius: 4px; margin: 14px 0; overflow: hidden; }
.mg-timer > div { height: 100%; background: var(--accent); width: 100%; }
.mg-body { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 16px; }

/* 티켓 미니게임 */
.ticket {
  width: 100%; max-width: 340px; background: var(--card); color: var(--card-ink);
  border-radius: 16px; box-shadow: var(--paper-shadow); padding: 22px; touch-action: none;
  text-align: center; min-height: 150px; display: flex; flex-direction: column; justify-content: center;
}
.ticket-tag { font-size: .72rem; color: #b8621f; font-weight: 800; }
.ticket-body { font-size: 1.1rem; font-weight: 700; margin-top: 10px; line-height: 1.5; }
.ticket-btns { display: flex; gap: 8px; width: 100%; max-width: 340px; }
.tbtn {
  flex: 1; padding: 13px 6px; border-radius: 12px; border: 1px solid var(--line);
  font-family: inherit; font-size: .92rem; font-weight: 800; cursor: pointer;
  background: var(--bg2); color: #eceef4; transition: transform .07s, border-color .12s;
}
.tbtn:active { transform: scale(.95); }
.tbtn.bad { border-bottom: 3px solid var(--danger); }
.tbtn.epic { border-bottom: 3px solid var(--accent); }
.tbtn.good { border-bottom: 3px solid var(--peer); }
.stamp {
  position: absolute; font-size: 1.6rem; font-weight: 900; padding: 6px 14px; border-radius: 10px;
  opacity: 0; z-index: 4;
}

/* 회의록 미니게임 */
.mtg-q { font-size: 1.1rem; font-weight: 700; text-align: center; min-height: 3em; }
.mtg-answers { display: flex; flex-direction: column; gap: 12px; width: 100%; max-width: 340px; }
.mtg-ans { background: var(--bg2); border: 1px solid var(--line); color: #eceef4; padding: 15px; border-radius: 12px; font-size: 1rem; font-family: inherit; cursor: pointer; }
.mtg-ans:active { border-color: var(--accent); }
.mtg-log { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; min-height: 2em; }
.mtg-chip { background: #23262e; color: var(--muted); font-size: .72rem; padding: 4px 10px; border-radius: 999px; }

/* 배포 타이밍 미니게임 */
.deploy-item { width: 100%; max-width: 340px; text-align: center; }
.deploy-label { font-size: 1rem; font-weight: 700; margin-bottom: 14px; }
.timing-track { position: relative; height: 40px; background: linear-gradient(90deg,#ff4d4d 0 30%,#ffcf4a 30% 42%,#7be0a4 42% 58%,#ffcf4a 58% 70%,#ff4d4d 70% 100%); border-radius: 10px; overflow: hidden; }
.timing-needle { position: absolute; top: -4px; bottom: -4px; width: 4px; background: #fff; box-shadow: 0 0 8px #fff; left: 0; }
.deploy-tap { margin-top: 22px; width: 100%; max-width: 340px; }
.deploy-dots { display: flex; gap: 8px; justify-content: center; margin-bottom: 8px; }
.deploy-dot { width: 12px; height: 12px; border-radius: 50%; background: #333844; }
.deploy-dot.green { background: var(--peer); }
.deploy-dot.yellow { background: var(--accent); }
.deploy-dot.red { background: var(--danger); }

/* ---------- 엔딩 ---------- */
.ending-wrap { margin: auto; text-align: center; padding: 20px; width: 100%; }
.ending-flash { font-size: 1.1rem; color: var(--muted); min-height: 1.4em; margin-bottom: 12px; }
.result-card-holder { display: flex; justify-content: center; }
#result-canvas { width: auto; max-width: 78%; max-height: 62dvh; border-radius: 14px; box-shadow: var(--paper-shadow); }
.ending-actions { display: flex; flex-direction: column; gap: 10px; margin-top: 20px; align-items: center; }
.ending-actions .btn { width: 100%; max-width: 300px; }
.share-toast { color: var(--peer); font-size: .82rem; min-height: 1.2em; margin-top: 10px; }

.card.enter { animation: cardIn .3s ease; }
@keyframes cardIn { from { transform: translateY(24px) scale(.96); opacity: 0; } }

/* ---------- 부활 제안 (리워드 광고 자리) ---------- */
.revive-wrap { margin: auto; text-align: center; padding: 30px 26px; width: 100%; max-width: 360px; }
.revive-flash { font-size: 1.15rem; font-weight: 800; margin: 0 0 8px; line-height: 1.5; }
.revive-sub { color: var(--muted); font-size: .9rem; margin: 0 0 26px; }
.ad-slot-tag {
  display: inline-block; border: 1px dashed #56607a; color: #8a94b0;
  font-size: .72rem; font-weight: 700; padding: 4px 12px; border-radius: 8px; margin-bottom: 12px;
}
#btn-revive { width: 100%; margin-bottom: 10px; }
#btn-giveup { width: 100%; }
.btn-ad { background: #2b6cb0; color: #fff; }

/* 광고 오버레이 (mock) */
.ad-overlay {
  position: absolute; inset: 0; z-index: 50; display: none;
  background: rgba(6,8,12,.94); align-items: center; justify-content: center;
}
.ad-overlay.show { display: flex; }
.ad-box { text-align: center; }
.ad-tv { font-size: 3.4rem; animation: tvPulse 1s infinite; }
.ad-playing { font-size: 1.05rem; font-weight: 800; margin-top: 12px; color: #eceef4; }
.ad-mock-note { font-size: .74rem; color: var(--muted); margin-top: 6px; }
@keyframes tvPulse { 50% { opacity: .4; transform: scale(.94); } }
