:root {
  --bg: #0b0a09;
  --panel: #131110;
  --line: #3a342c;
  --line-soft: #26221d;
  --text: #e4ded0;
  --dim: #8d8578;
  --red: #a3271f;
  --red-hi: #c8392e;
  --ok: #7fa468;
  --gold: #c9a35a;
  --serif: 'Nanum Myeongjo', 'Noto Serif KR', 'Batang', 'Times New Roman', serif;
  --sans: 'Pretendard', 'Noto Sans KR', 'Malgun Gothic', system-ui, sans-serif;
}
* {
  box-sizing: border-box;
}
html,
body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 16px;
  overflow: hidden;
  overscroll-behavior: none;
  word-break: keep-all;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}
[hidden] {
  display: none !important;
}
#view {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
}
.mono {
  font-family: 'Consolas', 'D2Coding', monospace;
  letter-spacing: 0.12em;
}
.dim {
  color: var(--dim);
}

/* ---------- menus */
#menu {
  position: fixed;
  inset: 0;
  overflow-y: auto;
  background: var(--bg);
}
#menu.over-game {
  background: rgba(8, 7, 6, 0.86);
}
.screen {
  min-height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px 16px calc(24px + env(safe-area-inset-bottom));
}
.title-wrap {
  text-align: center;
}
.eyebrow {
  margin: 0 0 10px;
  color: var(--dim);
  letter-spacing: 0.5em;
  font-size: 13px;
}
.title {
  margin: 0;
  font-family: var(--serif);
  font-weight: 800;
  font-size: clamp(44px, 9vw, 92px);
  letter-spacing: 0.08em;
  color: var(--text);
}
.title.small {
  font-size: clamp(24px, 4vw, 34px);
  letter-spacing: 0.1em;
}
.sub {
  margin: 8px 0 34px;
  font-family: var(--serif);
  letter-spacing: 0.9em;
  text-indent: 0.9em;
  color: var(--red-hi);
  font-size: 14px;
}
h2 {
  margin: 0 0 14px;
  font-family: var(--serif);
  font-size: 24px;
  letter-spacing: 0.06em;
}
h3 {
  margin: 22px 0 8px;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.2em;
  color: var(--dim);
}
.panel {
  width: 100%;
  background: var(--panel);
  border: 1px solid var(--line);
  padding: 24px;
}
.panel.narrow {
  max-width: 400px;
}
.panel.wide {
  max-width: 820px;
}
.panel.two {
  display: grid;
  grid-template-columns: minmax(180px, 280px) 1fr;
  gap: 24px;
}
.row {
  display: flex;
  gap: 10px;
  align-items: center;
}
.row.wrap {
  flex-wrap: wrap;
}
.row.end {
  justify-content: flex-end;
  margin-top: 20px;
}
.row.between {
  justify-content: space-between;
  margin-top: 18px;
}
.row.between:first-child {
  margin-top: 0;
}
.col {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.btn {
  appearance: none;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 15px;
  padding: 11px 18px;
  cursor: pointer;
  min-height: 44px;
}
.btn:hover {
  border-color: var(--dim);
}
.btn:disabled {
  color: #5c564d;
  border-color: var(--line-soft);
  cursor: default;
}
.btn.primary {
  background: var(--red);
  border-color: var(--red);
  color: #fff;
}
.btn.primary:hover {
  background: var(--red-hi);
}
.btn.primary:disabled {
  background: #3a1a17;
  border-color: #3a1a17;
  color: #8d7a76;
}
.btn.big {
  font-size: 17px;
  padding: 14px 26px;
}
.btn.danger {
  color: var(--red-hi);
}
.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 14px;
  font-size: 13px;
  color: var(--dim);
}
input,
select {
  font: inherit;
  color: var(--text);
  background: #0c0b0a;
  border: 1px solid var(--line);
  padding: 11px 12px;
  min-height: 44px;
  -webkit-user-select: text;
  user-select: text;
}
input[type='range'] {
  padding: 0;
  accent-color: var(--red-hi);
}
.preview {
  border: 1px solid var(--line-soft);
  background: #0c0b0a;
  aspect-ratio: 3 / 4;
  position: relative;
}
.preview canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}
.swatches {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.swatch {
  width: 34px;
  height: 34px;
  border: 1px solid var(--line);
  cursor: pointer;
  padding: 0;
  font: inherit;
  font-size: 12px;
  color: var(--text);
  background: #0c0b0a;
}
.swatch.text {
  width: auto;
  padding: 0 10px;
}
.swatch.on {
  outline: 2px solid var(--text);
  outline-offset: 1px;
}

.bar {
  width: 100%;
  max-width: 980px;
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 8px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 12px;
  margin-bottom: 20px;
}
.who {
  display: flex;
  gap: 14px;
  align-items: baseline;
}
.sc b {
  color: var(--gold);
}
.lobby {
  width: 100%;
  max-width: 980px;
  display: grid;
  grid-template-columns: minmax(200px, 300px) 1fr;
  gap: 28px;
  align-items: start;
}
.join {
  display: flex;
  gap: 10px;
  margin-top: 12px;
}
.join input {
  width: 170px;
}
.links {
  margin-top: 24px;
}
.list {
  list-style: none;
  margin: 0;
  padding: 0;
  border-top: 1px solid var(--line-soft);
}
.list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 2px;
  border-bottom: 1px solid var(--line-soft);
}
.list li.empty {
  color: var(--dim);
  justify-content: flex-start;
}
.list .name {
  font-weight: 600;
}
.list .meta {
  color: var(--dim);
  font-size: 13px;
}
.jobs li > div:first-child {
  flex: 1;
}
.price {
  color: var(--gold);
  white-space: nowrap;
}
.code {
  font-size: 30px;
  color: var(--gold);
}
.diffs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.diffs .btn.on {
  border-color: var(--text);
  background: #1d1a17;
}
.codex {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 14px;
}
.codex article {
  border: 1px solid var(--line-soft);
  padding: 12px;
}
.codex img {
  width: 100%;
  aspect-ratio: 3 / 4;
  object-fit: contain;
  background: #d9d6cf;
  display: block;
}
.codex h4 {
  margin: 10px 0 4px;
  font-family: var(--serif);
  font-size: 19px;
}
.codex p {
  margin: 4px 0;
  font-size: 13px;
  line-height: 1.55;
  color: #bdb6a7;
}
.codex .tip {
  color: var(--ok);
}
.steps {
  padding-left: 20px;
  line-height: 1.75;
}
.keys-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}
.keys-table th,
.keys-table td {
  text-align: left;
  padding: 7px 8px;
  border-bottom: 1px solid var(--line-soft);
}
.keys-table th {
  color: var(--dim);
  font-weight: 500;
}
.progress {
  width: min(360px, 76vw);
  height: 3px;
  background: var(--line-soft);
  margin: 26px auto 12px;
}
.progress i {
  display: block;
  height: 100%;
  width: 0;
  background: var(--red-hi);
  transition: width 0.25s;
}
#notice {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translateX(-50%);
  background: #1d1a17;
  border: 1px solid var(--line);
  padding: 10px 16px;
  z-index: 50;
  font-size: 14px;
  max-width: 90vw;
}

/* ---------- in game */
#hud {
  position: fixed;
  inset: 0;
  pointer-events: none;
}
.vignette {
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at center, rgba(0, 0, 0, 0) 52%, rgba(0, 0, 0, 0.72) 100%);
}
#danger {
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at center, rgba(120, 0, 0, 0) 45%, rgba(120, 0, 0, 0.55) 100%);
  opacity: 0;
}
#flash,
#fade {
  position: absolute;
  inset: 0;
  background: #000;
  opacity: 0;
}
.hud-top {
  position: absolute;
  top: calc(10px + env(safe-area-inset-top));
  left: calc(12px + env(safe-area-inset-left));
  right: calc(12px + env(safe-area-inset-right));
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  font-size: 14px;
  text-shadow: 0 1px 2px #000;
}
.hud-block {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.hud-block.right {
  align-items: flex-end;
}
.hud-row {
  display: flex;
  gap: 8px;
  align-items: center;
}
.hud-row .k {
  color: #a59d8e;
  font-size: 12px;
  min-width: 48px;
}
.hud-row .v {
  font-weight: 700;
}
.pips {
  display: inline-flex;
  gap: 4px;
}
.pips i {
  width: 12px;
  height: 12px;
  border: 1px solid #a59d8e;
  display: block;
}
.pips i.on {
  background: var(--red-hi);
  border-color: var(--red-hi);
}
.tag {
  border: 1px solid #a59d8e;
  padding: 2px 8px;
  font-size: 12px;
}
.tag.ok {
  border-color: var(--ok);
  color: var(--ok);
}
#toasts {
  position: absolute;
  top: 22%;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  gap: 6px;
  align-items: center;
  width: min(92vw, 560px);
}
.toast {
  background: rgba(8, 7, 6, 0.78);
  border-left: 2px solid #a59d8e;
  padding: 8px 14px;
  font-size: 15px;
  text-align: center;
  transition: opacity 0.4s;
}
.toast.item {
  border-color: var(--gold);
}
.toast.seal {
  border-color: var(--red-hi);
  font-family: var(--serif);
  font-size: 17px;
}
.toast.sc {
  border-color: var(--gold);
  color: var(--gold);
}
#cross {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 4px;
  height: 4px;
  margin: -2px;
  background: rgba(228, 222, 208, 0.7);
}
#prompt {
  position: absolute;
  left: 50%;
  top: 60%;
  transform: translateX(-50%);
  background: rgba(8, 7, 6, 0.78);
  border: 1px solid var(--line);
  padding: 10px 16px;
  font: inherit;
  font-size: 15px;
  color: inherit;
  white-space: nowrap;
  cursor: pointer;
}
#objective {
  position: absolute;
  top: calc(10px + env(safe-area-inset-top));
  left: 50%;
  transform: translateX(-50%);
  max-width: min(46vw, 520px);
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 4px 10px;
  font-size: 15px;
  text-align: center;
  text-shadow: 0 1px 2px #000;
  pointer-events: none;
}
#objective .k {
  color: #a59d8e;
}
#o-way {
  display: inline-flex;
  gap: 6px;
  align-items: center;
  color: #d9c9a0;
}
#o-arrow {
  display: inline-block;
  font-style: normal;
  font-size: 13px;
  line-height: 1;
}
.goal-steps {
  margin: 0 0 8px;
  padding-left: 22px;
  line-height: 1.7;
}
#guide h2 + .guide-phone,
#guide .dim + h2 {
  margin-top: 14px;
}
#prompt kbd {
  font: inherit;
  font-weight: 700;
  border: 1px solid #a59d8e;
  padding: 0 7px;
  margin-right: 8px;
}
#prompt.info {
  color: #a59d8e;
}
#status {
  position: absolute;
  left: 50%;
  bottom: 22%;
  transform: translateX(-50%);
  font-family: var(--serif);
  font-size: 20px;
  text-align: center;
  text-shadow: 0 1px 3px #000;
}
.hud-bottom {
  position: absolute;
  left: 50%;
  bottom: calc(18px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
}
.stamina {
  width: min(240px, 46vw);
  height: 5px;
  background: rgba(228, 222, 208, 0.16);
}
.stamina i {
  display: block;
  height: 100%;
  width: 100%;
  background: #d8d2c2;
}
.stamina.tired i {
  background: var(--red-hi);
}
#ability-pc {
  position: absolute;
  right: 16px;
  bottom: 16px;
  border: 1px solid var(--line);
  background: rgba(8, 7, 6, 0.7);
  padding: 8px 12px;
  font-size: 14px;
}
#touch {
  position: absolute;
  inset: 0;
  pointer-events: auto;
  touch-action: none;
}
#touch .tbtn,
#touch .stick {
  display: none;
}
#touch.on .tbtn {
  display: block;
}
.stick {
  position: absolute;
  width: 112px;
  height: 112px;
  margin: -56px;
  border: 1px solid rgba(228, 222, 208, 0.35);
  border-radius: 50%;
}
#touch.on .stick {
  display: block;
  left: calc(100px + env(safe-area-inset-left));
  bottom: calc(160px + env(safe-area-inset-bottom));
}
.stick span {
  position: absolute;
  left: 0;
  right: 0;
  top: 100%;
  margin-top: 6px;
  text-align: center;
  font-size: 12px;
  color: rgba(228, 222, 208, 0.75);
}
.stick.on span {
  display: none;
}
.stick i {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 46px;
  height: 46px;
  border-radius: 50%;
  background: rgba(228, 222, 208, 0.4);
  transform: translate(-50%, -50%);
}
.tbtn {
  position: absolute;
  appearance: none;
  border: 1px solid rgba(228, 222, 208, 0.4);
  background: rgba(8, 7, 6, 0.45);
  color: var(--text);
  font: inherit;
  font-size: 14px;
  width: 72px;
  height: 72px;
  border-radius: 50%;
}
.tbtn.on {
  background: rgba(200, 57, 46, 0.55);
  border-color: var(--red-hi);
}
.tbtn.act {
  right: calc(22px + env(safe-area-inset-right));
  bottom: calc(96px + env(safe-area-inset-bottom));
  width: 84px;
  height: 84px;
}
.tbtn.run {
  right: calc(118px + env(safe-area-inset-right));
  bottom: calc(36px + env(safe-area-inset-bottom));
}
.tbtn.ability {
  right: calc(120px + env(safe-area-inset-right));
  bottom: calc(126px + env(safe-area-inset-bottom));
}
.tbtn.flash {
  right: calc(22px + env(safe-area-inset-right));
  bottom: calc(196px + env(safe-area-inset-bottom));
  width: 58px;
  height: 58px;
  font-size: 12px;
}
.tbtn.menu {
  right: calc(12px + env(safe-area-inset-right));
  top: calc(84px + env(safe-area-inset-top));
  width: 52px;
  height: 36px;
  border-radius: 0;
  font-size: 12px;
}
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 20;
}
#k-display {
  font-size: 34px;
  text-align: center;
  border: 1px solid var(--line);
  background: #020a04;
  color: #55ff7a;
  padding: 10px;
  margin: 12px 0;
}
.keys {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 14px;
}
.keys .btn {
  font-size: 20px;
}

@media (max-width: 720px) {
  #objective {
    top: calc(76px + env(safe-area-inset-top));
    width: 92vw;
    max-width: 92vw;
  }
  #toasts {
    top: 24%;
  }
  .panel.two,
  .lobby {
    grid-template-columns: 1fr;
  }
  .preview {
    max-width: 200px;
    margin: 0 auto;
    width: 100%;
  }
  .panel {
    padding: 18px 14px;
  }
  .screen {
    justify-content: flex-start;
  }
  #s-boot,
  #s-loading {
    justify-content: center;
  }
  .hud-row .k {
    min-width: 40px;
  }
}
@media (max-height: 480px) {
  #toasts {
    top: 16%;
  }
  .tbtn.flash {
    bottom: calc(190px + env(safe-area-inset-bottom));
  }
}

/* a catch scene takes the whole screen */
body[data-cut]:not([data-cut='']) #toasts,
body[data-cut]:not([data-cut='']) #prompt,
body[data-cut]:not([data-cut='']) #objective,
body[data-cut]:not([data-cut='']) #cross,
body[data-cut]:not([data-cut='']) .hud-top,
body[data-cut]:not([data-cut='']) .hud-bottom {
  visibility: hidden;
}

#look-hint {
  display: none;
  position: absolute;
  right: calc(120px + env(safe-area-inset-right));
  top: 38%;
  max-width: 44vw;
  padding: 8px 12px;
  background: rgba(8, 7, 6, 0.7);
  border: 1px solid var(--line);
  font-size: 13px;
  text-align: center;
  pointer-events: none;
}
#touch.on #look-hint.show {
  display: block;
}
#key-legend {
  position: absolute;
  left: 14px;
  bottom: 14px;
  font-size: 12px;
  color: rgba(228, 222, 208, 0.6);
  text-shadow: 0 1px 2px #000;
}
#click-hint {
  position: absolute;
  left: 50%;
  top: 42%;
  transform: translateX(-50%);
  background: rgba(8, 7, 6, 0.82);
  border: 1px solid var(--line);
  padding: 10px 16px;
  font-size: 15px;
  white-space: nowrap;
}
body.touch #key-legend,
body.touch #click-hint {
  display: none;
}
.guide-phone {
  display: grid;
  grid-template-columns: 1fr 1fr;
  border: 1px solid var(--line);
  margin-bottom: 14px;
}
.guide-phone .zone {
  padding: 18px 12px;
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13px;
  color: #bdb6a7;
}
.guide-phone .zone + .zone {
  border-left: 1px dashed var(--line);
}
.guide-phone b {
  color: var(--text);
  font-size: 15px;
}
#guide .panel {
  max-height: 100%;
  overflow-y: auto;
}
body[data-cut]:not([data-cut='']) #key-legend,
body[data-cut]:not([data-cut='']) #click-hint {
  visibility: hidden;
}
