/* ============================================================
   主布局：三栏 + 顶栏 + 输入行
   ============================================================ */
.app {
  position: relative;
  z-index: 1;
  display: grid;
  height: 100vh;
  grid-template-columns: var(--w-side) minmax(0, 1fr) var(--w-aside);
  grid-template-rows: var(--h-head) minmax(0, 1fr) var(--h-action) var(--h-input);
  grid-template-areas:
    "head head head"
    "side main aside"
    "act act act"
    "input input input";
}

/* ---------- 顶栏 ---------- */
.app__head {
  grid-area: head;
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 0 22px;
  border-bottom: 1px solid var(--line-soft);
  background: linear-gradient(180deg, var(--ink-2), var(--ink-1));
  position: relative;
  min-width: 0;
}

.app__head::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: -1px;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(93, 202, 165, 0.35) 22%, rgba(93, 202, 165, 0.35) 78%, transparent);
  opacity: 0.5;
}

/* 手机上的抽屉开关。桌面上左栏一直摆着，这个按钮不该存在 */
.head__menu {
  display: none;
  place-items: center;
  width: 34px;
  height: 34px;
  flex: none;
  font-size: 15px;
  line-height: 1;
  color: var(--t-1);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  transition: all 0.16s var(--ease);
}

.head__menu:active {
  color: var(--qing);
  border-color: var(--qing-dim);
}

.brand {
  font-family: var(--serif);
  font-size: 16px;
  letter-spacing: 0.34em;
  color: var(--t-0);
  white-space: nowrap;
}

.brand__dot {
  display: inline-block;
  width: 4px;
  height: 4px;
  margin-left: 2px;
  border-radius: 50%;
  background: var(--qing);
  box-shadow: 0 0 6px var(--qing);
  animation: pulse 3s ease-in-out infinite;
  vertical-align: middle;
}

.head__mid {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 12px;
  color: var(--t-2);
  margin-left: 8px;
}

.head__loc {
  color: var(--t-1);
}

/* 坐标：和地名分开一格。
   以前想把坐标塞进地名里（"落雁城 · 6,5"），那就丢了"东荒"这一层——
   玩家在地图上找不到自己在哪一域。 */
.head__xy {
  font-family: var(--mono);
  font-size: 11.5px;
  letter-spacing: 0.02em;
  color: var(--qing);
  opacity: 0.9;
}

.head__sep {
  color: var(--t-3);
}

/* 这一局是真连着后端，还是本地演示。小，但要看得见——
   连没连上后端，会决定玩家以为"我刚才走的那步算不算数"。 */
.head__mode {
  font-size: 10.5px;
  letter-spacing: .08em;
  color: var(--qing);
  border: 1px solid rgba(127, 212, 255, .28);
  border-radius: 3px;
  padding: 1px 5px 0;
  opacity: .8;
}

.head__right {
  margin-left: auto;
  display: flex;
  gap: 6px;
}

.btn-ghost {
  padding: 5px 11px;
  font-size: 12px;
  color: var(--t-1);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  transition: all 0.18s var(--ease);
  white-space: nowrap;
}

.btn-ghost:hover {
  color: var(--t-0);
  border-color: var(--line-bright);
  background: var(--ink-3);
}

.btn-ghost:active {
  transform: translateY(1px);
}

/* ---------- 左栏 ---------- */
.app__side {
  grid-area: side;
  border-right: 1px solid var(--line-soft);
  background: var(--ink-1);
  padding: 18px 18px 16px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  /* 14 而不是 20：900 高的屏上，差这十几像素，
     最底下那截行囊就正好卡在动作条外面看不全 */
  gap: 14px;
  scrollbar-width: thin;
  scrollbar-color: var(--line-bright) transparent;
}

.app__side::-webkit-scrollbar,
.app__aside::-webkit-scrollbar {
  width: 6px;
}

.app__side::-webkit-scrollbar-thumb,
.app__aside::-webkit-scrollbar-thumb {
  background: var(--line-bright);
  border-radius: 3px;
}

.app__side::-webkit-scrollbar-track,
.app__aside::-webkit-scrollbar-track {
  background: transparent;
}

/* ---------- 中间终端 ---------- */
.app__main {
  grid-area: main;
  min-width: 0;
  position: relative;
  overflow: hidden;
  /* 引路条要占在终端上面一行，所以这里得是纵向 flex。
     原来是块级 + terminal 高度 100%，引导条一插进去就会把终端顶出屏幕 */
  display: flex;
  flex-direction: column;
}

.terminal {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 22px 30px 40px;
  scroll-behavior: smooth;
}

/* ---------- 右栏 ---------- */
.app__aside {
  grid-area: aside;
  border-left: 1px solid var(--line-soft);
  background: var(--ink-1);
  padding: 18px 18px 16px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 18px;
  scrollbar-width: thin;
  scrollbar-color: var(--line-bright) transparent;
}

/* ---------- 输入行 ---------- */
.app__input {
  grid-area: input;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 26px;
  border-top: 1px solid var(--line-soft);
  background: var(--ink-2);
  position: relative;
  min-width: 0;
}

.app__input::before {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: -1px;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(217, 164, 65, 0.28) 30%, rgba(217, 164, 65, 0.28) 70%, transparent);
  opacity: 0.6;
}

.prompt {
  color: var(--qing);
  font-size: 15px;
  user-select: none;
  opacity: 0.85;
}

#cmd {
  flex: 1;
  font-size: 14px;
  letter-spacing: 0.02em;
  caret-color: var(--qing);
  background: transparent;
}

#cmd::placeholder {
  color: var(--t-3);
}

.input-hint {
  font-size: 11px;
  color: var(--t-3);
  white-space: nowrap;
  user-select: none;
}

.input-hint kbd {
  font-family: var(--mono);
  font-size: 10px;
  padding: 1px 5px;
  border: 1px solid var(--line);
  border-radius: 2px;
  color: var(--t-2);
  background: var(--ink-3);
}

/* ---------- 窄屏 ---------- */
@media (max-width: 1180px) {
  .app {
    grid-template-columns: var(--w-side) minmax(0, 1fr);
    grid-template-areas:
      "head head"
      "side main"
      "act act"
      "input input";
  }
  .app__aside {
    display: none;
  }
}

@media (max-width: 820px) {
  .app {
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas:
      "head"
      "main"
      "act"
      "input";
  }
  .app__side {
    display: none;
  }
  .head__mid {
    display: none;
  }
  .app__head {
    padding: 0 14px;
    gap: 10px;
  }
  .brand {
    font-size: 14px;
    letter-spacing: 0.2em;
  }
  .head__right {
    gap: 4px;
  }
  .btn-ghost {
    padding: 4px 8px;
    font-size: 11px;
  }
  .terminal {
    padding: 16px 18px 32px;
  }
  .input-hint {
    display: none;
  }
  .app__input {
    padding: 0 16px;
  }
}

@media (max-width: 520px) {
  .head__right .btn-ghost:nth-child(n + 3) {
    display: none;
  }
}
