* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  background: #1a2418;
  color: #e2e8d2;
  font-family: "Courier New", monospace;
  font-size: 16px;
  min-height: 100vh;
}

.screen { display: none; min-height: 100vh; }
.screen.active { display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 1rem; }

.terminal {
  background: #0d140c;
  border: 2px solid #4a5d3a;
  border-radius: 4px;
  max-width: 720px;
  width: 100%;
  padding: 2rem;
  box-shadow: 0 0 40px rgba(120, 200, 80, 0.15);
}

h1 { color: #8fd05a; font-size: 2rem; margin-bottom: 0.5rem; }
h2 { color: #8fd05a; font-size: 1.1rem; margin: 0.5rem 0; }
.sub { color: #a8b890; margin-bottom: 1.5rem; }
.line { color: #6fc040; line-height: 1.8; white-space: pre-wrap; }
.line::before { content: "> "; color: #4a7a30; }
.dim { color: #93a381; }
.dim::before { content: ""; }

.btn {
  margin-top: 1.5rem;
  padding: 0.6rem 1.4rem;
  background: #24301e;
  color: #8fd05a;
  border: 2px solid;
  border-color: #6a7a58 #2a3a24 #2a3a24 #6a7a58;
  font-family: inherit;
  font-size: 1rem;
  cursor: pointer;
}
.btn:hover { background: #31422a; }
.btn:active { border-color: #2a3a24 #6a7a58 #6a7a58 #2a3a24; }
.btn.primary { background: #3a5a24; color: #e8f0d8; }
.btn:disabled { opacity: 0.4; cursor: default; }

.hidden { display: none !important; }

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}
.sound-control:not([hidden]) {
  position: sticky;
  top: .4rem;
  z-index: 2;
  display: flex;
  justify-content: flex-end;
  padding: .4rem .65rem 0;
  pointer-events: none;
}
.sound-control .btn {
  margin: 0;
  padding: .4rem .7rem;
  font-size: .85rem;
  pointer-events: auto;
}
.sound-control:not([hidden]) ~ .screen { min-height: calc(100vh - 2.65rem); }

/* ============ 프롤로그 채팅 ============ */
.terminal.chat { max-width: 640px; }

#chat-log, #chat-log-2006, #chat-log-twist {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  max-height: 42vh;
  overflow-y: auto;
  margin: 1rem 0;
  padding-right: 0.4rem;
}

.bubble {
  max-width: 80%;
  padding: 0.55rem 0.9rem;
  border-radius: 4px;
  line-height: 1.5;
  white-space: pre-wrap;
  animation: pop 0.2s ease-out;
}
.bubble .who {
  display: block;
  font-size: 0.7rem;
  opacity: 0.7;
  margin-bottom: 0.15rem;
  letter-spacing: 0.05em;
}
@keyframes pop {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}
.bubble.ai {
  align-self: flex-start;
  background: #0d140c;
  border: 1px solid #3a5a24;
  color: #9fd070;
}
.bubble.player {
  align-self: flex-end;
  background: #2a4a6a;
  border: 1px solid #4a6a8a;
  color: #e8f0f8;
}
.bubble.boss {
  align-self: flex-start;
  background: #b8ab84;
  border: 1px solid #8a7f5a;
  color: #3a3423;
}
.bubble.with-portrait {
  display: flex;
  align-items: flex-start;
  gap: .6rem;
}
.bubble.with-portrait img {
  flex: none;
  image-rendering: pixelated;
}
.bubble.with-portrait div {
  min-width: 0;
  word-break: keep-all;
  overflow-wrap: anywhere;
}

#agent-term-wrap {
  border: 1px solid #2a3a24;
  background: #060a05;
  margin: 0.8rem 0;
}
.term-title {
  font-size: 0.75rem;
  color: #4a7a30;
  padding: 0.3rem 0.6rem;
  border-bottom: 1px solid #2a3a24;
  letter-spacing: 0.08em;
}
#agent-term {
  height: 6.5rem;
  overflow-y: auto;
  padding: 0.5rem 0.6rem;
  color: #6fc040;
  font-size: 0.85rem;
  line-height: 1.6;
  text-shadow: 0 0 6px rgba(120, 220, 80, 0.4);
}
#agent-term::after { content: "▊"; animation: blink 0.8s steps(1) infinite; }
@keyframes blink { 50% { opacity: 0; } }

#intro-buttons, #buttons-2006 { display: flex; flex-direction: column; gap: 0.5rem; }
#intro-buttons .btn, #buttons-2006 .btn { margin-top: 0; text-align: left; }

/* 짜증 단계 */
#screen-intro.anger-1 .bubble.player { background: #4a3a1a; }
#screen-intro.anger-2 .bubble.player { background: #5a2a1a; animation: pop 0.2s ease-out, shake 0.3s ease-in-out; }
#screen-intro.anger-3 .bubble.player { background: #6a1a1a; color: #ffd8c8; animation: pop 0.2s ease-out, shake 0.2s ease-in-out 2; }
#screen-intro.anger-3 .terminal { border-color: #7a3a2a; box-shadow: 0 0 40px rgba(220, 80, 50, 0.25); }
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-3px); }
  75% { transform: translateX(3px); }
}

/* 시간 이동 */
#screen-travel { background: #000; }
#travel-box {
  position: relative;
  max-width: 640px;
  width: 100%;
  padding: 2rem;
  border: 1px solid #2a3a24;
  animation: glitch 0.25s steps(2) infinite;
}
#travel-box::after {
  content: "";
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(0deg, rgba(120, 255, 120, 0.05) 0 2px, transparent 2px 4px);
  pointer-events: none;
}
@keyframes glitch {
  0% { transform: translate(0, 0); filter: none; }
  25% { transform: translate(-3px, 2px); filter: hue-rotate(40deg); }
  50% { transform: translate(3px, -2px); filter: none; }
  75% { transform: translate(-2px, -1px); filter: hue-rotate(-40deg); }
  100% { transform: translate(0, 0); }
}
#travel-log {
  color: #6fc040;
  font-size: 1.05rem;
  line-height: 2;
  min-height: 9rem;
  text-shadow: 0 0 8px rgba(120, 220, 80, 0.6);
}

/* 2006 레트로 터미널 */
.terminal.retro {
  background: #cfc5a2;
  border: 3px ridge #8a7f5a;
  box-shadow: 0 0 40px rgba(0, 0, 0, 0.4);
}
.terminal.retro .line.dim { color: #6a5f3a; }
.terminal.retro .bubble.ai {
  background: #0d140c;
  border: 1px solid #3a5a24;
  color: #6fc040;
  text-shadow: 0 0 6px rgba(120, 220, 80, 0.5);
}
.terminal.retro .bubble.player { background: #7a8a9a; color: #f0f0e8; border-color: #5a6a7a; }
.terminal.retro .btn { background: #b8ab84; color: #3a3423; border-color: #e8e0c8 #6a5f3a #6a5f3a #e8e0c8; }
.terminal.retro .btn:hover { background: #a89a72; }

/* 타이틀 카드 */
#screen-titlecard { background: #0d140c; }
.titlecard { text-align: center; }
.bigtitle {
  font-size: 3rem;
  color: #8fd05a;
  text-shadow: 0 0 20px rgba(120, 220, 80, 0.5);
  animation: pop 0.4s ease-out;
}
.tagline { color: #d8e0c8; margin-top: 0.8rem; font-size: 1.1rem; }
.tagline2 { color: #6a7a58; margin-top: 0.4rem; }

/* ============ 메인 게임 ============ */
#screen-office.active { justify-content: flex-start; gap: 0.6rem; padding: 0.6rem; }

/* HUD */
#hud {
  width: 100%;
  max-width: 1200px;
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  background: #b8ab84;
  border: 3px solid;
  border-color: #e8e0c8 #6a5f3a #6a5f3a #e8e0c8;
  padding: 0.4rem 0.8rem;
  color: #2e2a1c;
  font-size: 1rem;
}
.hud-item { display: flex; align-items: center; gap: 0.4rem; }
.hud-label { font-size: 0.8rem; color: #5a4f2a; }
.hud-val { min-width: 2.2em; }
.bar {
  width: 90px;
  height: 12px;
  background: #8a7f5a;
  border: 1px solid #6a5f3a;
}
.bar-fill { height: 100%; transition: width 0.4s ease; }
.bar-fill.hp { background: #c05050; }
.bar-fill.prog { background: #4a7a30; }
/* 레이아웃 */
#office-main {
  width: 100%;
  max-width: 1200px;
  display: grid;
  grid-template-columns: 340px 1fr;
  gap: 0.6rem;
  align-items: start;
}
#left-col { display: flex; flex-direction: column; gap: 0.6rem; }

/* 사무실 씬 */
#office-scene {
  background: #0d140c;
  border: 3px solid;
  border-color: #e8e0c8 #6a5f3a #6a5f3a #e8e0c8;
}
#scene-svg { display: block; width: 100%; image-rendering: pixelated; }
#scene-caption {
  font-size: 0.72rem;
  color: #6a7a58;
  padding: 0.2rem 0.5rem;
  border-top: 1px solid #2a3a24;
}


/* 김 과장 대화 */
#boss-dialog {
  display: flex;
  gap: 0.6rem;
  background: #cfc5a2;
  border: 3px solid;
  border-color: #e8e0c8 #6a5f3a #6a5f3a #e8e0c8;
  padding: 0.6rem;
  color: #3a3423;
  min-height: 84px;
}
#boss-face { width: 56px; height: 56px; flex: none; }
#boss-face svg, #boss-face img { width: 100%; height: 100%; object-fit: contain; image-rendering: pixelated; }
#boss-text .speaker { font-weight: bold; font-size: 0.9rem; color: #5a4a1a; }
#boss-text p { line-height: 1.6; margin-top: 0.2rem; font-size: 1.02rem; }
.act-btn {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.15rem;
  padding: 0.45rem 0.6rem;
  background: #b8ab84;
  color: #3a3423;
  border: 2px solid;
  border-color: #e8e0c8 #6a5f3a #6a5f3a #e8e0c8;
  font-family: inherit;
  font-size: 0.95rem;
  cursor: pointer;
  text-align: left;
}
.act-btn:hover { background: #c8bd94; }
.act-btn:active { border-color: #6a5f3a #e8e0c8 #e8e0c8 #6a5f3a; }
.act-btn:disabled { opacity: 0.45; cursor: default; }
.act-btn .cost { font-size: 0.78rem; color: #5a4f2a; }

/* 미션 + 에디터 */
#work-panel {
  background: #0d140c;
  border: 3px solid;
  border-color: #6a7a58 #2a3a24 #2a3a24 #6a7a58;
  padding: 0.8rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
#mission-panel {
  background: #cfc5a2;
  color: #2e2a1c;
  border: 2px solid #8a7f5a;
  padding: 0.9rem;
  font-size: 1rem;
}
#mission-panel h2 { color: #3a5a24; margin-top: 0; }
#mission-panel p { line-height: 1.65; margin-bottom: 0.5rem; }
.grammar { font-size: 0.95rem; color: #4a4232; background: #e8e0c8; padding: 0.4rem 0.5rem; border-left: 3px solid #8a7f5a; }
.example {
  background: #060a05;
  color: #b8e888;
  padding: 0.5rem 0.6rem;
  font-size: 0.95rem;
  margin-bottom: 0.45rem;
  white-space: pre-wrap;
}
.example.out { color: #e8d888; border-left: 3px solid #8a7f3a; }
.req { font-weight: bold; }
.expect code { background: #e8e0c8; padding: 0.1rem 0.4rem; }
.hint {
  background: #e8d8a8;
  border: 1px dashed #8a7f5a;
  padding: 0.4rem 0.5rem;
  font-size: 0.9rem;
}
.hint::before { content: "박 대리: "; font-weight: bold; }

.editor-head {
  display: flex;
  justify-content: space-between;
  color: #6a7a58;
  font-size: 0.85rem;
}
.warn { color: #d08a4a; }

#editor {
  width: 100%;
  min-height: 260px;
  background: #060a05;
  color: #ccf29a;
  border: 1px solid #3a4a2e;
  padding: 0.8rem;
  font-family: "Courier New", monospace;
  font-size: 1.08rem;
  line-height: 1.6;
  resize: vertical;
  tab-size: 4;
}
#editor:focus { outline: 1px solid #6fc040; }

.actions { display: flex; gap: 0.6rem; }
.actions .btn { margin-top: 0; }
.submit-help {
  background: #292213;
  border-left: 3px solid #bf9753;
  color: #f3deb0;
  padding: .6rem .75rem;
  font-size: .92rem;
  line-height: 1.6;
}
.submit-help .btn { margin-top: .45rem; }
#scrum-panel {
  padding: .8rem;
  background: #182318;
  border: 1px solid #56694e;
  color: #e2e8d2;
  line-height: 1.6;
  word-break: keep-all;
  overflow-wrap: anywhere;
}
#scrum-panel h2 { margin: 0 0 .35rem; font-size: 1rem; color: #b9cfaa; }
#scrum-totals {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(5.5rem, 1fr));
  gap: .35rem;
  margin: .55rem 0;
}
#scrum-totals:empty { display: none; }
#scrum-totals div { background: #253322; padding: .28rem .5rem; }
#scrum-totals dt { color: #b9cfaa; font-size: .78rem; }
#scrum-previous { color: #b9cfaa; font-size: .88rem; }
#scrum-previous:empty { display: none; }
#scrum-today { margin-top: .5rem; }
#scrum-history { margin-top: .5rem; }
#scrum-history summary { cursor: pointer; color: #cddd9c; }
#scrum-promises { padding-inline-start: 1.2rem; margin-top: .35rem; }
.record-awards { margin-top: .55rem; color: #cddd9c; }
@media (max-width: 480px) {
  #scrum-totals { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

#output {
  background: #060a05;
  border: 1px solid #3a4a2e;
  padding: 0.8rem;
  min-height: 90px;
  font-size: 1rem;
  line-height: 1.6;
  color: #b8e888;
  white-space: pre-wrap;
  word-break: break-all;
}
#output.error { color: #d07070; }
#output.ok { color: #8fd05a; }

/* AI 생성 대사 출처 */
.ai-tag {
  display: inline-block;
  margin-inline-start: .35rem;
  padding: .07rem .3rem;
  border-radius: 2px;
  background: #37452d;
  color: #fbf4db;
  font-size: .7rem;
  font-weight: 700;
  line-height: 1.25;
}

:root { color-scheme: dark; }
body { background: radial-gradient(ellipse at top, #253322 0, #151e14 46rem); }
button, input, select, textarea { font: inherit; }
button:focus-visible, input:focus-visible, select:focus-visible, summary:focus-visible {
  outline: 3px solid #b8e888;
  outline-offset: 2px;
}

#screen-title .terminal { padding: clamp(1.25rem, 5vw, 3rem); }
#screen-title h1 { font-size: clamp(2.1rem, 6vw, 3.4rem); }
.game-version {
  display: inline-block;
  color: #a8b890;
  font-size: .4em;
  letter-spacing: .04em;
  vertical-align: middle;
}
#screen-office.active { padding: clamp(.65rem, 2vw, 1.5rem); gap: .8rem; }
#hud { column-gap: 1.15rem; row-gap: .55rem; }
#office-title { margin-left: auto; padding: .3rem .75rem; }
#office-main { gap: .8rem; grid-template-columns: minmax(220px, 285px) minmax(0, 1fr); }
#left-col { gap: .7rem; }
#scene-caption { color: #a8b890; padding: .4rem .55rem; }
#boss-line, #shift-story { overflow-wrap: anywhere; }

#relation-panel, #schedule {
  background: #10190e;
  border: 1px solid #4a5d3a;
  padding: .75rem .85rem;
}
#relation-panel summary, #mission-help summary, #history-list summary { cursor: pointer; }
#relation-panel p { color: #a8b890; margin: .65rem 0; font-size: .85rem; }
#relations, #history-list dl { display: grid; grid-template-columns: 1fr auto; gap: .35rem 1rem; }
#relations dd, #history-list dd { text-align: right; color: #b8e888; }
#schedule { list-style: none; padding: .4rem; color: #abbca1; }
#schedule li { padding: .42rem .5rem; font-size: .87rem; }
#schedule [aria-current] {
  background: #314523;
  border-left: 3px solid #adce79;
  color: #f4f6eb;
  font-weight: bold;
}

#work-panel { min-width: 0; padding: .85rem; gap: .8rem; }
#shift-panel {
  background: #cfc5a2;
  border: 2px solid #8a7f5a;
  color: #2e2a1c;
  padding: clamp(.9rem, 3vw, 1.4rem);
}
#shift-title { color: #263d1c; font-size: clamp(1.3rem, 3vw, 1.9rem); }
#shift-title:focus { outline: none; }
.phase-clock { color: #4d472d; font-weight: bold; margin-bottom: .35rem; }
#shift-story { white-space: pre-line; line-height: 1.7; }
#shift-effects { padding-inline-start: 1.25rem; margin-top: .8rem; line-height: 1.6; }
#shift-effects:empty { display: none; }

#choices { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .45rem; }
#choices .act-btn { min-height: 44px; justify-content: center; line-height: 1.4; }
#coding-panel { display: grid; gap: .55rem; min-width: 0; }
#mission-help { margin: .6rem 0; }
#mission-help > summary { padding-block: .3rem; font-weight: bold; }
#mission-help .grammar { margin-top: .3rem; }
#mission-panel pre { overflow-wrap: anywhere; }
.expect code { white-space: pre-wrap; overflow-wrap: anywhere; }
.editor-head { color: #a8b890; flex-wrap: wrap; gap: .2rem .6rem; }
#editor { min-height: 155px; font-size: .95rem; }
#output { min-height: 55px; }

#screen-ending .terminal { max-width: 620px; }
#ending-table { width: 100%; border-collapse: collapse; margin-block: 1rem; color: #d8e0c8; }
#ending-table th, #ending-table td { border-bottom: 1px solid #3a4a2e; padding: .55rem .4rem; }
#ending-table th { font-weight: normal; text-align: left; }
#ending-table td { text-align: right; }
.award { color: #e8c860; list-style-position: inside; line-height: 1.55; }
.best { color: #a7b69a; font-size: .85rem; margin-top: .7rem; }
.credits-end { color: #b8e888; font-size: 1.45rem; letter-spacing: .15em; }

#account-form {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: .65rem;
  margin-block: .7rem 1.25rem;
}
#account-form label { display: grid; gap: .3rem; }
#account-form p { grid-column: 1 / -1; font-size: .85rem; }
#account-form .btn { margin-top: 0; }
#account-form input, #rank-category {
  width: 100%;
  min-width: 0;
  padding: .55rem;
  background: #080d07;
  border: 1px solid #6a7a58;
  border-radius: 0;
  color: #e2e8d2;
}
.record-category { display: flex; align-items: center; gap: .6rem; }
#rank-category { width: auto; max-width: 100%; }
.record-actions, #history-panel { margin-block: .8rem; }
#rank-list, #history-list { padding-top: .65rem; color: #d8e0c8; }
#rank-list ol { list-style: none; }
#rank-list li { display: flex; justify-content: space-between; gap: 1rem; padding: .55rem 0; border-bottom: 1px solid #3a4a2e; }
#history-list details { border: 1px solid #3a4a2e; padding: .55rem; margin-bottom: .45rem; }
#history-list dl { margin-top: .6rem; font-size: .9rem; }

@media (max-width: 740px) {
  #office-main { grid-template-columns: minmax(0, 1fr); }
  #work-panel { grid-row: 1; }
  #schedule { display: none; }
  #office-title { margin-left: 0; }
  .terminal { padding: clamp(1rem, 5vw, 2rem); }
}
@media (max-width: 390px) {
  #choices .act-btn:not(.ticket-choice) { grid-column: 1 / -1; }
  #account-form { grid-template-columns: 1fr; }
  #ending-table { font-size: .9rem; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
