@font-face {
  font-family: "NeoDunggeunmo";
  src:
    url("/font/neodgm.woff2") format("woff2"),
    url("/font/neodgm.woff") format("woff"),
    url("/font/neodgm.ttf") format("truetype");
  font-display: swap;
}

:root {
  color-scheme: dark;
  --bg: #080c0a;
  --panel: #0d1714;
  --panel-soft: #07100d;
  --line: #246c7a;
  --text: #e3fff9;
  --muted: #7fb8c4;
  --accent: #7ed7ff;
  --accent-strong: #b8f0ff;
  --button: #11242a;
  --cyan: #7ed7ff;
  --red: #ff7777;
  --green: #8fe28f;
  --fishing: #ffd86b;
  --fishing-strong: #fff2b8;
  --map-zoom: 1;
}

@keyframes ansi-blink {
  50% {
    opacity: 0;
  }
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html,
body {
  height: 100%;
  margin: 0;
  overflow: hidden;
  background:
    linear-gradient(rgba(255, 255, 255, 0.022) 50%, rgba(0, 0, 0, 0.045) 50%),
    radial-gradient(circle at 50% 0%, #10242d 0, var(--bg) 58%);
  background-size: 100% 4px, auto;
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Noto Sans KR", "Segoe UI", system-ui, sans-serif;
}

.map-shell {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  width: 100vw;
  height: 100vh;
  overflow: hidden;
}

.map-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
  background: #0c1411;
  box-shadow: inset 0 -1px 0 color-mix(in srgb, var(--line) 65%, transparent);
}

h1 {
  margin: 0;
  color: var(--accent-strong);
  font-size: 18px;
  font-weight: 750;
  text-shadow: 0 0 10px color-mix(in srgb, var(--accent) 35%, transparent);
}

p {
  margin: 4px 0 0;
  color: var(--muted);
}

nav {
  display: flex;
  gap: 8px;
  align-items: center;
}

a,
button {
  min-height: 36px;
  display: inline-grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 2px;
  background: var(--button);
  color: var(--text);
  padding: 0 12px;
  font: inherit;
  text-decoration: none;
  cursor: pointer;
}

a:hover,
button:hover {
  border-color: var(--accent);
  color: var(--accent-strong);
  background: color-mix(in srgb, var(--button) 72%, var(--accent) 14%);
}

.map-layout {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr) 360px;
  width: 100%;
  min-height: 0;
  overflow: hidden;
}

body.detail-collapsed .map-layout {
  grid-template-columns: 280px minmax(0, 1fr) 54px;
}

body.detail-collapsed .detail-panel {
  display: block;
}

body.detail-collapsed .detail-panel .detail-content,
body.detail-collapsed .detail-panel .detail-empty,
body.detail-collapsed #detail-file {
  display: none;
}

body.detail-collapsed .detail-panel .panel-head {
  height: 100%;
  min-height: 0;
  flex-direction: column;
  justify-content: flex-start;
  padding: 10px 6px;
}

body.detail-collapsed .detail-panel .panel-head strong {
  writing-mode: vertical-rl;
  text-orientation: mixed;
}

body.detail-collapsed .detail-head-actions {
  justify-content: center;
}

body.detail-collapsed #detail-toggle {
  width: 38px;
  min-width: 38px;
  padding: 0;
  writing-mode: vertical-rl;
}

.directory-panel,
.room-panel,
.detail-panel {
  min-width: 0;
  min-height: 0;
  border-right: 1px solid var(--line);
  background:
    linear-gradient(rgba(255, 255, 255, 0.012) 50%, rgba(0, 0, 0, 0.035) 50%),
    var(--panel);
  background-size: 100% 4px, auto;
  overflow: hidden;
}

.detail-panel {
  border-right: 0;
}

.panel-head,
.room-toolbar {
  min-height: 54px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px;
  border-bottom: 1px solid var(--line);
  background: #0c1411;
}

.detail-head-actions {
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

#detail-file {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#detail-toggle,
.toggle-button {
  min-height: 32px;
  padding: 0 10px;
}

.toggle-button {
  color: var(--muted);
}

.toggle-button.active {
  color: var(--accent-strong);
  background: color-mix(in srgb, var(--button) 78%, var(--accent) 12%);
}

.room-toolbar input {
  width: min(360px, 42vw);
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 2px;
  background: #020403;
  color: var(--text);
  padding: 0 10px;
  font: inherit;
}

.view-tabs {
  display: inline-grid;
  grid-template-columns: repeat(3, auto);
  border: 1px solid var(--line);
  border-radius: 2px;
  overflow: hidden;
  background: #07100d;
}

.view-tabs button {
  min-height: 32px;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--muted);
  padding: 0 10px;
}

.view-tabs button + button {
  border-left: 1px solid var(--line);
}

.view-tabs button.active {
  background: var(--button);
  color: var(--accent-strong);
}

.zoom-controls {
  display: inline-grid;
  grid-template-columns: 34px minmax(56px, auto) 34px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 2px;
  overflow: hidden;
  background: #07100d;
}

.zoom-controls button {
  min-height: 32px;
  border: 0;
  border-radius: 0;
  background: transparent;
  padding: 0;
  color: var(--text);
}

.zoom-controls button + span,
.zoom-controls span + button {
  border-left: 1px solid var(--line);
}

.zoom-controls button:disabled {
  color: color-mix(in srgb, var(--muted) 45%, transparent);
  cursor: default;
}

.zoom-controls span {
  min-height: 32px;
  display: inline-grid;
  place-items: center;
  padding: 0 8px;
  color: var(--accent-strong);
  font-size: 13px;
  white-space: nowrap;
}

.breadcrumbs {
  min-height: 36px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
}

.breadcrumbs button {
  min-height: 26px;
  padding: 0 7px;
  background: transparent;
}

.directory-list,
.room-grid,
.detail-empty,
.detail-content {
  height: calc(100% - 54px);
  overflow: auto;
}

.directory-list {
  height: calc(100% - 90px);
  padding: 8px;
}

.dir-button,
.room-card {
  width: 100%;
  display: block;
  text-align: left;
  border: 1px solid var(--line);
  border-radius: 2px;
  background: var(--panel-soft);
  color: var(--text);
  padding: calc(10px * var(--map-zoom));
}

.dir-button + .dir-button,
.room-card + .room-card {
  margin-top: 8px;
}

.dir-button strong,
.room-card strong {
  display: block;
  color: var(--accent-strong);
  font-size: calc(16px * var(--map-zoom));
}

.room-card p,
.room-card .lpc-path {
  font-size: calc(14px * var(--map-zoom));
}

.meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 7px;
}

.pill {
  display: inline-grid;
  place-items: center;
  min-height: calc(22px * var(--map-zoom));
  border: 1px solid color-mix(in srgb, var(--line) 70%, transparent);
  border-radius: 2px;
  color: var(--muted);
  padding: 0 calc(8px * var(--map-zoom));
  font-size: calc(12px * var(--map-zoom));
}

.pill.exit {
  color: var(--cyan);
}

.pill.mob {
  color: var(--red);
}

.pill.item {
  color: var(--green);
}

.pill.fishing {
  border-color: color-mix(in srgb, var(--fishing) 86%, transparent);
  color: var(--fishing-strong);
  background: color-mix(in srgb, var(--fishing) 14%, transparent);
}

.pill.warning {
  border-color: color-mix(in srgb, var(--fishing) 90%, transparent);
  color: var(--fishing-strong);
  background: color-mix(in srgb, var(--fishing) 16%, transparent);
}

.room-grid,
.graph-view,
.compass-view {
  height: calc(100% - 54px);
  overflow: auto;
  padding: 12px;
}

.graph-view {
  cursor: grab;
  user-select: none;
}

.graph-view.panning,
.graph-panning {
  cursor: grabbing;
}

.graph-stage {
  position: relative;
  min-width: 100%;
  min-height: 100%;
  border: 1px solid var(--line);
  border-radius: 2px;
  background:
    linear-gradient(rgba(126, 215, 255, 0.06) 1px, transparent 1px),
    linear-gradient(90deg, rgba(126, 215, 255, 0.06) 1px, transparent 1px),
    #010607;
  background-size: calc(44px * var(--map-zoom)) calc(44px * var(--map-zoom));
}

.graph-edges {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.graph-edges line {
  stroke: color-mix(in srgb, var(--accent) 48%, transparent);
  stroke-width: 2;
}

.graph-edges line.multi {
  stroke: color-mix(in srgb, var(--fishing) 62%, var(--accent) 28%);
  stroke-dasharray: 6 5;
}

.graph-node {
  position: absolute;
  width: calc(148px * var(--map-zoom));
  min-height: calc(48px * var(--map-zoom));
  display: block;
  text-align: left;
  border: 1px solid var(--line);
  border-radius: 2px;
  background: #07100d;
  color: var(--text);
  padding: calc(7px * var(--map-zoom)) calc(9px * var(--map-zoom));
  font-size: calc(14px * var(--map-zoom));
  box-shadow:
    0 0 0 1px #06130f,
    0 0 18px color-mix(in srgb, var(--accent) 10%, transparent);
}

.graph-node:hover,
.graph-node.selected {
  border-color: var(--accent);
  color: var(--accent-strong);
}

.graph-node strong {
  display: block;
  color: var(--accent-strong);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.graph-node span {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: calc(12px * var(--map-zoom));
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.graph-node.has-mob {
  border-color: color-mix(in srgb, var(--red) 70%, transparent);
}

.room-card.fishing-room,
.graph-node.fishing-room,
.graph-node.has-mob.fishing-room {
  border-color: var(--fishing);
  box-shadow:
    0 0 0 1px color-mix(in srgb, var(--fishing) 50%, transparent),
    0 0 18px color-mix(in srgb, var(--fishing) 24%, transparent);
}

.graph-node.fishing-room strong,
.room-card.fishing-room strong {
  color: var(--fishing-strong);
}

.graph-empty {
  padding: 16px;
  color: var(--muted);
}

.compass-view {
  display: grid;
  align-content: start;
  gap: 12px;
}

.compass-board {
  width: min(100%, calc(780px * var(--map-zoom)));
  margin: 0 auto;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  grid-template-areas:
    "north-west north north-east"
    "west center east"
    "south-west south south-east";
  gap: calc(10px * var(--map-zoom));
}

.compass-extras {
  width: min(100%, calc(780px * var(--map-zoom)));
  margin: 0 auto;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: calc(10px * var(--map-zoom));
}

.compass-cell {
  min-height: calc(116px * var(--map-zoom));
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: calc(6px * var(--map-zoom));
  border: 1px solid color-mix(in srgb, var(--line) 62%, transparent);
  border-radius: 2px;
  background:
    linear-gradient(rgba(126, 215, 255, 0.035) 1px, transparent 1px),
    #020807;
  background-size: calc(18px * var(--map-zoom)) calc(18px * var(--map-zoom));
  padding: calc(8px * var(--map-zoom));
}

.compass-cell.north-west { grid-area: north-west; }
.compass-cell.north { grid-area: north; }
.compass-cell.north-east { grid-area: north-east; }
.compass-cell.west { grid-area: west; }
.compass-cell.center { grid-area: center; }
.compass-cell.east { grid-area: east; }
.compass-cell.south-west { grid-area: south-west; }
.compass-cell.south { grid-area: south; }
.compass-cell.south-east { grid-area: south-east; }

.compass-dir {
  color: var(--muted);
  font-size: calc(12px * var(--map-zoom));
  font-weight: 700;
}

.compass-cell.empty {
  color: color-mix(in srgb, var(--muted) 70%, transparent);
  opacity: 0.72;
}

.compass-cell.empty strong,
.compass-cell.empty small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
}

.compass-room {
  width: 100%;
  min-height: 100%;
  display: block;
  text-align: left;
  border-color: var(--line);
  background: color-mix(in srgb, var(--panel-soft) 88%, #000 12%);
  padding: calc(8px * var(--map-zoom));
}

.compass-room.current {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--button) 78%, var(--accent) 10%);
  box-shadow:
    inset 0 0 0 1px color-mix(in srgb, var(--accent) 45%, transparent),
    0 0 20px color-mix(in srgb, var(--accent) 18%, transparent);
}

.compass-room.self-loop {
  border-color: var(--fishing);
  background: color-mix(in srgb, var(--fishing) 16%, var(--panel-soft) 84%);
  box-shadow:
    inset 0 0 0 1px color-mix(in srgb, var(--fishing) 50%, transparent),
    0 0 16px color-mix(in srgb, var(--fishing) 18%, transparent);
}

.compass-room strong {
  display: block;
  color: var(--accent-strong);
  font-size: calc(15px * var(--map-zoom));
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.compass-room small,
.compass-cell.empty small {
  display: block;
  margin-top: calc(4px * var(--map-zoom));
  color: var(--muted);
  font-size: calc(12px * var(--map-zoom));
  word-break: break-all;
}

.compass-exit {
  display: inline-grid;
  place-items: center;
  min-height: calc(22px * var(--map-zoom));
  margin-top: calc(7px * var(--map-zoom));
  border: 1px solid color-mix(in srgb, var(--accent) 48%, transparent);
  color: var(--accent-strong);
  padding: 0 calc(7px * var(--map-zoom));
  font-size: calc(12px * var(--map-zoom));
}

.room-card {
  cursor: pointer;
}

.room-card:hover,
.room-card.selected {
  border-color: var(--accent);
}

.room-card p {
  line-height: 1.35;
}

.room-long {
  white-space: pre-wrap;
}

.detail-empty {
  padding: 16px;
  color: var(--muted);
}

.detail-content {
  padding: 14px;
}

.detail-content h2 {
  margin: 0 0 6px;
  color: var(--accent-strong);
  font-size: 20px;
}

.detail-section {
  border-top: 1px solid var(--line);
  padding-top: 12px;
  margin-top: 12px;
}

.detail-warning {
  border: 1px solid color-mix(in srgb, var(--fishing) 72%, transparent);
  background: color-mix(in srgb, var(--fishing) 10%, transparent);
  padding: 10px;
  margin-top: 12px;
}

.detail-warning h3 {
  margin: 0 0 8px;
  color: var(--fishing-strong);
  font-size: 15px;
}

.detail-warning p {
  margin: 4px 0 0;
  color: var(--text);
}

.detail-section h3 {
  margin: 0 0 8px;
  color: var(--cyan);
  font-size: 15px;
}

.detail-section ul {
  list-style: none;
  margin: 0;
  padding: 0;
}

.detail-section li {
  padding: 4px 0;
  color: var(--text);
}

.lpc-path {
  color: var(--muted);
  word-break: break-all;
}

@media (max-width: 1100px) {
  .map-layout {
    grid-template-columns: 240px minmax(0, 1fr);
  }

  .detail-panel {
    display: none;
  }
}

@media (max-width: 720px) {
  html,
  body {
    overflow: auto;
  }

  .map-shell {
    height: auto;
    min-height: 100vh;
  }

  .map-topbar,
  .room-toolbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .map-layout {
    display: block;
  }

  .directory-panel,
  .room-panel {
    height: auto;
    min-height: 320px;
  }

  .directory-list,
  .room-grid {
    height: auto;
    max-height: none;
  }

  .room-toolbar input {
    width: 100%;
  }
}
