:root {
  color-scheme: dark;
  --bg: #141311;
  --ink: #e4dccd;
  --dim: #9a9286;
  --line: rgba(228, 220, 205, 0.28);
  --red: #d2453a;
  --panel: #1c1b18;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(ellipse at center, transparent 0%, rgba(0, 0, 0, 0.45) 70%),
    var(--bg);
  color: var(--ink);
  font-family: "IBM Plex Sans KR", sans-serif;
}

.app {
  width: min(720px, calc(100% - 28px));
  margin: 0 auto;
  padding: 28px 0 48px;
}

.mark {
  width: min(280px, 70vw);
  aspect-ratio: 1;
  object-fit: cover;
  display: block;
  margin: 0 auto 18px;
  border: 1px solid var(--line);
}

.led {
  margin: 0;
  text-align: center;
  letter-spacing: 0.4em;
  color: var(--red);
  font-weight: 500;
  font-size: 28px;
}

.sub {
  margin: 6px 0 22px;
  text-align: center;
  color: var(--dim);
  font-size: 13px;
}

.panel {
  border: 1px solid var(--line);
  background: rgba(28, 27, 24, 0.92);
  padding: 18px;
}

.prose {
  margin: 0 0 8px;
  line-height: 1.7;
  font-size: 16px;
}

.now {
  margin: 0 0 16px;
  color: var(--red);
  line-height: 1.6;
}

.shop {
  margin: 4px 0 8px;
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.08em;
}

.bench, .locker {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.bench-row {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 10px;
  align-items: center;
}

form, .stats, .meters, .actions, .log {
  display: grid;
  gap: 10px;
}

label {
  display: grid;
  gap: 4px;
  color: var(--dim);
  font-size: 13px;
}

input, select {
  border: 1px solid var(--line);
  background: #100f0d;
  color: var(--ink);
  padding: 10px 12px;
  font: inherit;
}

.row, .actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

button {
  border: 1px solid var(--line);
  background: transparent;
  color: var(--ink);
  font: inherit;
  padding: 8px 12px;
  cursor: pointer;
}

button:hover { border-color: var(--ink); }

button:disabled {
  opacity: 0.35;
  cursor: default;
}

button.primary {
  background: var(--red);
  border-color: var(--red);
  color: #1a0d0c;
}

.meters {
  grid-template-columns: 1fr 1fr 1fr;
  margin-bottom: 12px;
}

.meter {
  border-top: 1px solid var(--line);
  padding-top: 8px;
  font-size: 13px;
  color: var(--dim);
}

.meter b {
  display: block;
  color: var(--ink);
  font-size: 18px;
  font-weight: 500;
}

.stat {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  border-top: 1px solid var(--line);
  padding-top: 8px;
}

.combat {
  color: var(--red);
  margin: 0 0 12px;
}

.log, .town {
  margin-top: 16px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
  color: var(--dim);
  font-size: 13px;
  line-height: 1.6;
}

.town h2, .here h2 {
  margin: 0 0 8px;
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.08em;
  color: var(--dim);
}

.feed-row, .here-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 6px;
}

.face, .letter {
  width: 28px;
  height: 28px;
  flex: 0 0 28px;
  object-fit: cover;
  aspect-ratio: 1;
  border: 1px solid var(--line);
}

.letter {
  display: grid;
  place-items: center;
  font-size: 12px;
  color: var(--ink);
}

.head {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}

.portrait, .portrait.letter {
  width: 72px;
  height: 72px;
  flex-basis: 72px;
  font-size: 22px;
}

.start-row {
  display: flex;
  justify-content: center;
  margin-top: 8px;
}

.notes {
  display: grid;
  gap: 4px;
  margin-top: 18px;
  text-align: center;
}

.notes p {
  margin: 0;
  color: var(--dim);
  font-size: 13px;
  line-height: 1.55;
}

.hint {
  margin: 0;
  color: var(--dim);
  font-size: 13px;
  line-height: 1.5;
}

.check {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--ink);
}

.ghost {
  background: none;
  border: none;
  padding: 0;
  color: var(--dim);
  text-decoration: underline;
}

.err { color: var(--red); min-height: 1.2em; margin: 0; }

.top {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin: 14px 0 0;
}

.veil {
  position: fixed;
  inset: 0;
  z-index: 5;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(0, 0, 0, 0.62);
}

.veil[hidden] { display: none; }

.sheet {
  width: min(440px, 100%);
  max-height: min(80vh, 640px);
  overflow: auto;
  padding: 16px;
  border: 1px solid var(--line);
  background: #1c1b18;
}

.sheet[hidden] { display: none; }

.sheet-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.sheet-bar h2 {
  margin: 0;
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.08em;
}

.inv {
  margin: 0 0 12px;
  padding: 0;
  list-style: none;
  color: var(--ink);
  line-height: 1.7;
}

.bag-skills {
  margin: 0 0 10px;
  color: var(--dim);
  font-size: 12px;
  letter-spacing: 0.02em;
}

.bag-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  margin: 0 0 12px;
}

.bag-slot {
  aspect-ratio: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 6px;
  border: 1px solid rgba(217, 208, 195, 0.45);
  background: #161411;
  text-align: center;
}

.bag-slot b {
  font-size: 18px;
  font-weight: 500;
  line-height: 1;
}

.bag-slot span {
  color: var(--dim);
  font-size: 11px;
  line-height: 1.2;
}

.chat {
  display: grid;
  gap: 8px;
  margin-top: 8px;
}

.chat-log {
  max-height: 140px;
  overflow: auto;
  padding: 8px;
  border: 1px solid var(--line);
  background: #100f0d;
}

.chat-log p {
  margin: 0 0 6px;
  font-size: 13px;
}

.chat-log b {
  margin-right: 6px;
  color: var(--dim);
  font-weight: 500;
}

.chat-empty {
  margin: 0;
  color: var(--dim);
  font-size: 13px;
}

.chat-send {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
}

.bar-where {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1 1 auto;
  min-width: 0;
}

.bar-where .bar-place {
  flex: 0 1 auto;
}

.admin-btn {
  padding: 4px 8px;
  font-size: 12px;
}

.admin-list {
  display: grid;
  gap: 8px;
}

.admin-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 2px 8px;
  width: 100%;
  padding: 8px;
  text-align: left;
  border: 1px solid var(--line);
  background: #161411;
}

.admin-row small {
  grid-column: 1 / -1;
  color: var(--dim);
}

#admin-detail {
  margin-top: 12px;
}

#admin-detail h3 {
  margin: 0 0 8px;
  font-size: 15px;
  font-weight: 500;
}

.clues {
  margin: 0 0 12px;
  color: var(--dim);
  font-size: 13px;
  line-height: 1.7;
}

.map {
  position: relative;
  height: 320px;
  margin: 4px 0 16px;
  overflow: hidden;
  border: 1px solid var(--line);
  background:
    radial-gradient(circle at 50% 54%, rgba(210, 69, 58, 0.08), transparent 46%),
    #100f0d;
}

.map svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.map line {
  stroke: rgba(228, 220, 205, 0.28);
  stroke-width: 0.4;
}

.map-node {
  position: absolute;
  transform: translate(-50%, -50%);
  width: 84px;
  padding: 8px 6px;
  background: #1c1b18;
  font-size: 13px;
  line-height: 1.35;
  text-align: center;
}

.map-node.here,
.map-node.here:disabled {
  opacity: 1;
  border-color: var(--red);
  color: var(--red);
  cursor: default;
}

.map-node small {
  display: block;
  font-size: 11px;
}

.map-node.locked { color: var(--dim); }

.floor-map { height: 420px; }

body:has(.app.play) {
  height: 100dvh;
  overflow: hidden;
}

.app.play {
  width: 100%;
  height: 100dvh;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
}

.dig-back {
  flex: 1 0 100%;
  margin: 0;
  color: var(--red);
  font-size: 13px;
  line-height: 1.4;
}

.bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 10px;
  padding: 8px 10px calc(8px + env(safe-area-inset-top));
  border-bottom: 1px solid var(--line);
  background: #141311;
}

.bar-led {
  color: var(--red);
  font-weight: 500;
  letter-spacing: 0.18em;
  font-size: 13px;
}

.bar-place {
  flex: 1 1 88px;
  font-size: 14px;
}

.bar-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  color: var(--dim);
  font-size: 12px;
}

.bar-stats b {
  color: var(--ink);
  font-weight: 500;
}

.app.play .top {
  margin: 0 0 0 auto;
}

.app.play .top button {
  padding: 6px 8px;
  font-size: 12px;
}

.app.play .stage {
  min-height: 0;
  display: flex;
}

.plan {
  flex: 1;
  min-height: 0;
  margin: 8px;
  display: grid;
  grid-template-rows: minmax(0, 1.15fr) auto minmax(0, 1.15fr);
  gap: 8px;
  padding: 10px;
  border: 1px solid rgba(217, 208, 195, 0.45);
  background: #100f0d;
}

.plan.lobby {
  grid-template-rows: minmax(0, 1.15fr) auto minmax(0, 0.9fr) 42px;
}

.plan-row {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 8px;
  min-height: 0;
}

.plan-row-2 { grid-template-columns: 1fr 1fr; }

.plan-hall {
  display: grid;
  grid-template-columns: 64px minmax(0, 1fr) 92px;
  gap: 8px;
  min-height: 78px;
  padding: 8px;
  border: 1px solid rgba(217, 208, 195, 0.45);
  background: #181512;
}

.plan.lobby .plan-hall { grid-template-columns: 64px minmax(0, 1fr); }

.plan-stairs {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-height: 0;
}

.plan-stairs .map-node {
  flex: 1;
  height: auto;
  min-height: 28px;
}

.plan-stairs .map-node[data-to="floor3"] {
  flex: 1.8;
  min-height: 40px;
}

.plan .map-node {
  position: relative;
  transform: none;
  width: auto;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 6px 4px;
  background: #221f1b;
  border: 1px solid rgba(217, 208, 195, 0.72);
}

.plan .map-node.locked {
  background: #121110;
  border-color: #6a5e56;
  color: var(--dim);
}

.plan .node-faces {
  position: static;
  transform: none;
  justify-content: center;
  margin-bottom: 4px;
}

.app.play .map,
.app.play .floor-map {
  height: 100%;
  margin: 0;
  border: 0;
}

.dock {
  max-height: 38dvh;
  overflow: auto;
  padding: 10px 12px calc(12px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
  background: #1c1b18;
}

.dock .now { margin-bottom: 8px; }

.node-faces {
  position: absolute;
  z-index: 2;
  display: flex;
  transform: translate(-50%, -130%);
  pointer-events: none;
}

.node-faces .face,
.node-faces .letter {
  width: 18px;
  height: 18px;
  flex-basis: 18px;
  margin-left: -5px;
  font-size: 9px;
}

@media (max-width: 720px) {
  .map-node {
    width: 68px;
    padding: 6px 4px;
    font-size: 12px;
  }

  .plan .map-node { width: auto; }
}
