/* 회색 상자 단계의 화면. 아트는 없다. (03 §8) */

:root {
  --bg: #071018;
  --panel: #0d1d28;
  --line: rgba(120, 220, 230, .16);
  --text: #dceaf0;
  --dim: #8aa4b0;
  --accent: #5ee0d0;
  --warn: #ffc861;
  --danger: #ff6b7d;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  overflow-x: hidden;         /* 세로 화면. 가로 스크롤 없음 (03 §7) */
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: "Pretendard", -apple-system, BlinkMacSystemFont, "Segoe UI", "Malgun Gothic", sans-serif;
  -webkit-text-size-adjust: 100%;
  -webkit-user-select: none;
  user-select: none;
}

#game {
  max-width: 480px;
  margin: 0 auto;
  padding: 14px 12px 24px;
}

/* ── HUD ────────────────────────────────────────────── */

.hud {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel);
  padding: 12px;
  margin-bottom: 12px;
}

.gauge-row {
  display: flex;
  align-items: center;
  gap: 9px;
}

.gauge-label {
  font-size: 12px;
  color: var(--dim);
  min-width: 30px;
}

.bar {
  flex: 1;
  height: 14px;
  border-radius: 7px;
  background: rgba(255, 255, 255, .07);
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  border-radius: 7px;
  background: var(--accent);
  transition: width 60ms linear;
}

.gauge-value {
  font-variant-numeric: tabular-nums;
  font-size: 12.5px;
  color: var(--dim);
  min-width: 78px;
  text-align: right;
}

/* 귀환 필요 산소 — 이 미션의 코어라서 가장 크게 보인다 (03 §5.3) */
.return-row {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
}

.return-label {
  font-size: 12px;
  color: var(--dim);
}

.return-value {
  font-size: 26px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  line-height: 1;
  color: var(--accent);
  transition: color 120ms ease;
}

.margin-value {
  margin-left: auto;
  font-size: 12.5px;
  font-variant-numeric: tabular-nums;
  color: var(--dim);
}

.return-row.critical .return-value { color: var(--warn); }
.return-row.critical .margin-value { color: var(--warn); }
.return-row.stranded .return-value { color: var(--danger); }
.return-row.stranded .margin-value { color: var(--danger); }

/* ── 바다 ───────────────────────────────────────────── */

.sea {
  position: relative;
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
  background: linear-gradient(180deg, #0d3242 0%, #04131c 100%);
}

.row {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 7px 8px;
  border-bottom: 1px solid rgba(255, 255, 255, .05);
  transition: background 120ms ease;
}

.row:last-of-type { border-bottom: 0; }

.row.surface {
  background: rgba(94, 224, 208, .08);
  border-bottom: 2px solid var(--accent);
}

.row.here { background: rgba(94, 224, 208, .10); }
.row.surface.here { background: rgba(94, 224, 208, .16); }

.row-label {
  font-size: 11px;
  color: var(--dim);
  min-width: 26px;
}

.row-drain {
  font-size: 10.5px;
  color: var(--dim);
  min-width: 34px;
  text-align: right;
  font-variant-numeric: tabular-nums;
  opacity: .7;
}

.cells {
  flex: 1;
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 3px;
}

.cell {
  aspect-ratio: 1;
  border-radius: 6px;
  background: rgba(255, 255, 255, .045);
}

/* 깊을수록 어둡게 — 깊이가 눈에 보여야 한다 */
.depth-2 .cell { background: rgba(255, 255, 255, .038); }
.depth-3 .cell { background: rgba(255, 255, 255, .030); }
.depth-4 .cell { background: rgba(255, 255, 255, .022); }

.diver {
  position: absolute;
  display: grid;
  place-items: center;
  font-size: 19px;
  pointer-events: none;
  transition: left 120ms ease;
  filter: drop-shadow(0 0 6px rgba(94, 224, 208, .55));
}

.diver.moving { filter: drop-shadow(0 0 10px rgba(94, 224, 208, .85)); }

/* ── 조작 ───────────────────────────────────────────── */

.controls {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 12px;
}

.btn {
  padding: 15px 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel);
  color: var(--text);
  font-size: 15px;
  font-family: inherit;
  cursor: pointer;
  transition: background 100ms ease, opacity 100ms ease;
}

.btn:active:not(:disabled) { background: rgba(94, 224, 208, .14); }

.btn:disabled {
  opacity: .3;
  cursor: default;
}

.btn.primary {
  border-color: rgba(94, 224, 208, .4);
  color: var(--accent);
}

.status {
  margin-top: 11px;
  min-height: 20px;
  font-size: 13px;
  color: var(--dim);
  text-align: center;
}

.status.ended { color: var(--text); font-weight: 600; }
.status.ended.drowned { color: var(--danger); }
.status.ended.returned { color: var(--accent); }

.restart-row {
  margin-top: 10px;
  text-align: center;
}

.restart-row button {
  padding: 9px 20px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: transparent;
  color: var(--dim);
  font-size: 12.5px;
  font-family: inherit;
  cursor: pointer;
}

.note {
  margin-top: 16px;
  padding: 11px 13px;
  border: 1px dashed var(--line);
  border-radius: 10px;
  font-size: 12px;
  line-height: 1.75;
  color: var(--dim);
}

.note b { color: var(--text); font-weight: 600; }

/* ── 추가 HUD (W2~W5) ───────────────────────────────── */

.top-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 9px;
  font-size: 12px;
  color: var(--dim);
}

.dive-label { color: var(--accent); font-weight: 700; }

.gauge-row + .gauge-row { margin-top: 7px; }
.bar-fill.bagfill { background: #8ea2ff; }
.bar-fill.arcana { background: linear-gradient(90deg, var(--accent), var(--warn)); }
.gauge-row.full .bar-fill.bagfill { background: var(--warn); }
.gauge-row.full .gauge-value { color: var(--warn); }

/* ── 자원 칸 ────────────────────────────────────────── */

.cell {
  display: grid;
  place-items: center;
  font-size: 15px;
  line-height: 1;
  transition: background 100ms ease, transform 100ms ease;
}

.row.layer .cell { cursor: pointer; }
.cell.has-item { background: rgba(255, 255, 255, .10); }
.row.here .cell.has-item { background: rgba(94, 224, 208, .18); }
.cell.has-item:active { transform: scale(.9); }

.cell.too-heavy { opacity: .35; }
.cell.picking {
  background: var(--warn);
  animation: pulse .6s ease-in-out infinite alternate;
}

@keyframes pulse { to { opacity: .55; } }

.cell.hidden-depth { color: var(--dim); font-size: 12px; opacity: .5; }
.row.empty .row-label { opacity: .35; text-decoration: line-through; }

.diver.working { filter: drop-shadow(0 0 12px var(--warn)); }

/* ── 가방 ───────────────────────────────────────────── */

.bag-box {
  margin-top: 10px;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel);
  min-height: 62px;
}

.bag-hint { font-size: 11px; color: var(--dim); margin-bottom: 7px; }
.bag-hint.dim { opacity: .45; }

.bag-list { display: flex; flex-wrap: wrap; gap: 6px; }

.chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 5px 9px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, .05);
  color: var(--text);
  font-family: inherit;
  font-size: 13px;
  cursor: pointer;
}

.chip:disabled { opacity: .5; cursor: default; }
.chip-w { font-size: 10.5px; color: var(--dim); font-variant-numeric: tabular-nums; }
.chip.dropping { background: var(--danger); animation: pulse .6s ease-in-out infinite alternate; }

/* ── 귀환 버튼 ──────────────────────────────────────── */

.return-btn {
  display: block;
  width: 100%;
  margin-top: 8px;
  padding: 17px;
  font-size: 17px;
  font-weight: 700;
  border-color: rgba(255, 200, 97, .35);
  color: var(--warn);
}

.return-btn.urgent {
  border-color: var(--danger);
  color: var(--danger);
  animation: pulse .7s ease-in-out infinite alternate;
}

/* ── 장비·결과 화면 ─────────────────────────────────── */

.screen { padding: 18px 2px 30px; }

.screen-title { font-size: 23px; margin: 0 0 6px; letter-spacing: -.01em; }
.screen-sub { font-size: 13px; color: var(--dim); margin: 0 0 16px; }
.group-title { font-size: 12px; color: var(--dim); margin: 18px 0 8px; font-weight: 600; letter-spacing: .04em; }

.option-list { display: grid; gap: 8px; }

.option {
  display: block;
  width: 100%;
  text-align: left;
  padding: 13px 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel);
  color: var(--text);
  font-family: inherit;
  cursor: pointer;
  transition: border-color 100ms ease, background 100ms ease;
}

.option.selected {
  border-color: var(--accent);
  background: rgba(94, 224, 208, .09);
}

.option-head { display: flex; justify-content: space-between; align-items: baseline; }
.option-name { font-size: 15.5px; font-weight: 700; }
.option-key { font-size: 12px; color: var(--accent); font-variant-numeric: tabular-nums; }

.traits { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 8px; }

.trait {
  font-size: 11px;
  padding: 3px 8px;
  border-radius: 999px;
}

.trait.gain { background: rgba(94, 224, 208, .14); color: var(--accent); }
.trait.cost { background: rgba(255, 107, 125, .14); color: var(--danger); }

.option-note { margin-top: 7px; font-size: 11.5px; color: var(--dim); }

.btn.big { display: block; width: 100%; margin-top: 20px; padding: 17px; font-size: 16px; font-weight: 700; }

/* ── 결과 ───────────────────────────────────────────── */

.dive-table { margin: 4px 0 16px; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }

.dive-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  font-size: 13px;
  border-bottom: 1px solid rgba(255, 255, 255, .05);
}

.dive-row:last-child { border-bottom: 0; }
.dive-no { color: var(--dim); min-width: 44px; }
.dive-tag { font-size: 11.5px; color: var(--accent); }
.dive-row.drowned .dive-tag { color: var(--danger); }
.dive-val { margin-left: auto; font-variant-numeric: tabular-nums; font-weight: 600; }

.summary {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 11px 13px;
  margin-bottom: 10px;
  background: var(--panel);
}

.summary.loss { border-color: rgba(255, 107, 125, .3); }
.summary-title { font-size: 11.5px; color: var(--dim); margin-bottom: 7px; }
.summary.loss .summary-title { color: var(--danger); }
.summary-empty { font-size: 13px; color: var(--dim); }

.summary-line { display: flex; align-items: center; gap: 8px; font-size: 13.5px; padding: 2px 0; }
.s-icon { width: 20px; }
.s-val { margin-left: auto; font-variant-numeric: tabular-nums; color: var(--dim); }
.summary.loss .s-val { color: var(--danger); }

.totals { margin: 14px 0; }
.total-line { display: flex; justify-content: space-between; padding: 4px 0; font-size: 14px; color: var(--dim); }
.total-value { color: var(--text); font-weight: 700; font-variant-numeric: tabular-nums; }

.progress-box {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px 13px;
  margin: 14px 0;
  background: var(--panel);
}

.progress-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 8px; font-size: 12.5px; color: var(--dim); }
.progress-pct { font-size: 19px; font-weight: 700; color: var(--accent); font-variant-numeric: tabular-nums; }
.progress-note { margin-top: 7px; font-size: 11.5px; color: var(--warn); }

.btn.upgrade { display: block; width: 100%; margin-top: 6px; padding: 13px; font-size: 13.5px; border-color: rgba(255, 200, 97, .3); color: var(--warn); }
.btn.upgrade:disabled { color: var(--dim); border-color: var(--line); }
.upgrade-done { margin-top: 6px; padding: 11px; text-align: center; font-size: 13px; color: var(--warn); border: 1px dashed rgba(255, 200, 97, .3); border-radius: 10px; }
