/* ============================================================
   style.css — 星夜像素小镇 UI 样式
   像素风三件套：硬边框(box-shadow 描边)、无圆角、Press Start 2P
   ============================================================ */

:root {
  --ink: #e8f0ff;
  --ink-dim: #aab4d4;
  --paper: rgba(11, 16, 38, 0.78);
  --paper-solid: #16204a;
  --edge: #e8f0ff;
  --accent: #ffd88a;
  --warm: #ffb85c;
  --danger: none;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #0b1026;
}

/* 3D 画布：小尺寸内部渲染，最近邻放大出像素颗粒 */
#stage {
  position: fixed;
  inset: 0;
}
#stage canvas {
  width: 100% !important;
  height: 100% !important;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  display: block;
}

#ui {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 10;
  font-family: "Press Start 2P", "PingFang SC", "Microsoft YaHei", sans-serif;
  color: var(--ink);
}

/* ------------------------------------------------------------
   HUD 左上：标题 / 时钟 / 提示
   ------------------------------------------------------------ */
.hud {
  position: absolute;
  top: 18px;
  left: 18px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  animation: hud-in 0.9s cubic-bezier(0.2, 0.8, 0.2, 1) both 0.4s;
}

.hud-title {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.hud-zh {
  font-family: "PingFang SC", "Microsoft YaHei", sans-serif;
  font-weight: 700;
  font-size: 26px;
  letter-spacing: 10px;
  text-shadow: 0 2px 0 #0b1026, 0 0 18px rgba(255, 216, 138, 0.35);
}
.hud-en {
  font-size: 10px;
  letter-spacing: 4px;
  color: var(--accent);
  text-shadow: 0 2px 0 #0b1026;
}

.hud-clock {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  align-self: flex-start;
  background: var(--paper);
  padding: 7px 10px;
  box-shadow:
    0 0 0 2px var(--edge),
    4px 4px 0 rgba(11, 16, 38, 0.55);
  font-size: 11px;
  color: var(--accent);
}

/* HUD 状态条（第 N 天 · 季节 · 天气） */
.hud-status {
  align-self: flex-start;
  font-family: "PingFang SC", "Microsoft YaHei", sans-serif;
  font-size: 12px;
  letter-spacing: 2px;
  color: var(--ink);
  background: var(--paper);
  padding: 5px 10px;
  box-shadow:
    0 0 0 2px rgba(232, 240, 255, 0.5),
    3px 3px 0 rgba(11, 16, 38, 0.55);
  text-shadow: 0 1px 0 #0b1026;
}
/* 手绘小时钟图标（纯 CSS 像素方块） */
.hud-clock-icon {
  width: 10px;
  height: 10px;
  position: relative;
  background:
    linear-gradient(var(--ink), var(--ink)) no-repeat 50% 0 / 2px 4px,
    linear-gradient(var(--ink), var(--ink)) no-repeat 50% 50% / 4px 2px,
    transparent;
  box-shadow: inset 0 0 0 2px var(--ink);
}

.hud-hints {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-family: "PingFang SC", "Microsoft YaHei", sans-serif;
  font-size: 12px;
  color: var(--ink-dim);
  text-shadow: 0 1px 0 #0b1026;
  opacity: 0.85;
}

@keyframes hud-in {
  from { transform: translateX(-18px); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

/* ------------------------------------------------------------
   重置按钮（右下）
   ------------------------------------------------------------ */
.reset-btn {
  pointer-events: auto;
  position: absolute;
  right: 18px;
  bottom: 172px; /* 右下角自下而上：D-pad → 图鉴 → 重置 */
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--paper);
  color: var(--ink);
  border: none;
  cursor: pointer;
  padding: 9px 12px;
  font-family: "PingFang SC", "Microsoft YaHei", sans-serif;
  font-size: 12px;
  letter-spacing: 2px;
  box-shadow:
    0 0 0 2px var(--edge),
    4px 4px 0 rgba(11, 16, 38, 0.55);
  transition: transform 0.12s steps(2), background 0.12s;
}
.reset-btn:hover {
  background: var(--paper-solid);
  transform: translate(-1px, -1px);
  box-shadow:
    0 0 0 2px var(--accent),
    5px 5px 0 rgba(11, 16, 38, 0.55);
}
.reset-btn:active {
  transform: translate(2px, 2px);
  box-shadow:
    0 0 0 2px var(--edge),
    2px 2px 0 rgba(11, 16, 38, 0.55);
}
.reset-btn svg {
  display: block;
}

/* ------------------------------------------------------------
   建筑名牌（底部居中，像素对话框）
   ------------------------------------------------------------ */
.plaque {
  position: absolute;
  left: 50%;
  bottom: 42px;
  transform: translate(-50%, 14px);
  width: min(420px, calc(100vw - 32px));
  background: var(--paper);
  box-shadow:
    0 0 0 2px var(--edge),
    6px 6px 0 rgba(11, 16, 38, 0.55);
  padding: 14px 16px 10px;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.18s steps(3), transform 0.18s steps(3), visibility 0.18s;
}
.plaque.show {
  opacity: 1;
  visibility: visible;
  transform: translate(-50%, 0);
}
.plaque-name {
  font-family: "PingFang SC", "Microsoft YaHei", sans-serif;
  font-weight: 700;
  font-size: 17px;
  letter-spacing: 6px;
  color: var(--accent);
  margin-bottom: 8px;
  text-shadow: 0 1px 0 #0b1026;
}
.plaque-blurb {
  font-family: "PingFang SC", "Microsoft YaHei", sans-serif;
  font-size: 13px;
  line-height: 1.8;
  color: var(--ink);
}
.plaque-tip {
  margin-top: 8px;
  font-size: 9px;
  letter-spacing: 2px;
  color: var(--ink-dim);
  opacity: 0.7;
}

/* ------------------------------------------------------------
   加载过场：像素块拼合 + 标题
   ------------------------------------------------------------ */
.boot-overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: #0b1026;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 26px;
  transition: opacity 0.6s steps(6), visibility 0.6s;
}
.boot-overlay.done {
  opacity: 0;
  visibility: hidden;
}
.boot-grid {
  display: grid;
  grid-template-columns: repeat(8, 22px);
  grid-template-rows: repeat(5, 22px);
  gap: 4px;
}
.boot-cell {
  background: #16204a;
  box-shadow: inset 0 0 0 1px #0b1026;
  transition: background 0.12s steps(2);
}
.boot-cell.on {
  background: var(--accent);
  box-shadow: inset 0 0 0 1px #0b1026, 0 0 10px rgba(255, 216, 138, 0.35);
}
.boot-title {
  font-family: "Press Start 2P", monospace;
  font-size: 14px;
  letter-spacing: 6px;
  color: var(--ink);
  text-shadow: 0 2px 0 #0b1026;
  animation: boot-blink 1.2s steps(2) infinite;
}
@keyframes boot-blink {
  50% { opacity: 0.55; }
}

/* ------------------------------------------------------------
   小镇图鉴（右侧面板）
   ------------------------------------------------------------ */
.guide-btn {
  pointer-events: auto;
  position: absolute;
  right: 18px;
  bottom: 120px; /* D-pad 上方 */
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--paper);
  color: var(--ink);
  border: none;
  cursor: pointer;
  padding: 9px 12px;
  font-family: "PingFang SC", "Microsoft YaHei", sans-serif;
  font-size: 12px;
  letter-spacing: 2px;
  box-shadow:
    0 0 0 2px var(--edge),
    4px 4px 0 rgba(11, 16, 38, 0.55);
  transition: transform 0.12s steps(2), background 0.12s;
}
.guide-btn:hover,
.guide-btn:active {
  background: var(--paper-solid);
}
.guide-btn:hover {
  transform: translate(-1px, -1px);
  box-shadow:
    0 0 0 2px var(--accent),
    5px 5px 0 rgba(11, 16, 38, 0.55);
}
.guide-btn svg { display: block; }

.guide {
  pointer-events: auto;
  position: absolute;
  right: 18px;
  top: 74px;
  bottom: 110px;
  width: min(300px, calc(100vw - 36px));
  display: flex;
  flex-direction: column;
  background: var(--paper);
  box-shadow:
    0 0 0 2px var(--edge),
    6px 6px 0 rgba(11, 16, 38, 0.55);
  opacity: 0;
  visibility: hidden;
  transform: translateX(14px);
  transition: opacity 0.18s steps(3), transform 0.18s steps(3), visibility 0.18s;
}
.guide.open {
  opacity: 1;
  visibility: visible;
  transform: translateX(0);
}
.guide-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  box-shadow: 0 2px 0 rgba(232, 240, 255, 0.25);
}
.guide-title {
  font-family: "PingFang SC", "Microsoft YaHei", sans-serif;
  font-weight: 700;
  font-size: 14px;
  letter-spacing: 4px;
  color: var(--accent);
}
.guide-close {
  pointer-events: auto;
  background: none;
  border: none;
  color: var(--ink-dim);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  padding: 2px 6px;
}
.guide-close:hover { color: var(--ink); }

.guide-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  scrollbar-width: thin;
  scrollbar-color: var(--ink-dim) transparent;
}
.guide-item {
  pointer-events: auto;
  text-align: left;
  background: rgba(232, 240, 255, 0.06);
  border: none;
  border-left: 3px solid var(--ink-dim);
  cursor: pointer;
  padding: 8px 10px;
  color: var(--ink);
  font-family: "PingFang SC", "Microsoft YaHei", sans-serif;
  transition: background 0.12s, border-color 0.12s;
}
.guide-item:hover {
  background: rgba(255, 216, 138, 0.12);
  border-left-color: var(--accent);
}
.guide-item-name {
  display: block;
  font-weight: 700;
  font-size: 13px;
  letter-spacing: 2px;
  margin-bottom: 3px;
}
.guide-item-blurb {
  display: block;
  font-size: 11px;
  line-height: 1.6;
  color: var(--ink-dim);
}
.guide-foot {
  padding: 8px 12px;
  font-size: 10px;
  letter-spacing: 2px;
  color: var(--ink-dim);
  box-shadow: 0 -2px 0 rgba(232, 240, 255, 0.25);
}

/* 屏幕方向键（D-pad，右下角十字） */
.dpad {
  pointer-events: auto;
  position: absolute;
  right: 18px;
  bottom: 18px;
  display: grid;
  grid-template-columns: repeat(3, 40px);
  grid-template-rows: repeat(2, 40px);
  gap: 4px;
  z-index: 15;
  touch-action: none;
  user-select: none;
}
.dpad-gap { pointer-events: none; }
.dpad-btn {
  pointer-events: auto;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--paper);
  color: var(--ink);
  border: none;
  cursor: pointer;
  padding: 0;
  box-shadow:
    0 0 0 2px rgba(232, 240, 255, 0.5),
    3px 3px 0 rgba(11, 16, 38, 0.55);
}
.dpad-btn.on,
.dpad-btn:active {
  background: var(--accent);
  color: #16204a;
  box-shadow:
    0 0 0 2px var(--edge),
    1px 1px 0 rgba(11, 16, 38, 0.55);
}
.dpad-up { grid-column: 2; grid-row: 1; }
.dpad-left { grid-column: 1; grid-row: 2; }
.dpad-down { grid-column: 2; grid-row: 2; }
.dpad-right { grid-column: 3; grid-row: 2; }

/* 店内环视提示 */
.shop-tip {
  position: absolute;
  left: 50%;
  bottom: 76px;
  transform: translateX(-50%);
  font-family: "PingFang SC", "Microsoft YaHei", sans-serif;
  font-size: 12px;
  letter-spacing: 2px;
  color: var(--ink-dim);
  background: var(--paper);
  padding: 6px 12px;
  box-shadow:
    0 0 0 2px rgba(232, 240, 255, 0.4),
    3px 3px 0 rgba(11, 16, 38, 0.55);
  pointer-events: none;
}

/* 出门按钮（进店模式，底部居中；最高层，任何东西都别挡它） */
.exit-shop-btn {
  pointer-events: auto;
  position: absolute;
  left: 50%;
  bottom: 26px;
  transform: translateX(-50%);
  z-index: 45;
  background: var(--paper);
  color: var(--ink);
  border: none;
  cursor: pointer;
  padding: 10px 22px;
  font-family: "PingFang SC", "Microsoft YaHei", sans-serif;
  font-size: 14px;
  letter-spacing: 4px;
  box-shadow:
    0 0 0 2px var(--edge),
    4px 4px 0 rgba(11, 16, 38, 0.55);
}
.exit-shop-btn:hover {
  background: var(--paper-solid);
  color: var(--accent);
}

/* ------------------------------------------------------------
   剧情通知 toast（底部像素条，队列滑入）
   ------------------------------------------------------------ */
.toasts {
  position: absolute;
  left: 50%;
  bottom: 120px;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
  pointer-events: none;
  z-index: 20;
}
.toast {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-width: min(520px, calc(100vw - 40px));
  background: var(--paper);
  box-shadow:
    0 0 0 2px var(--edge),
    5px 5px 0 rgba(11, 16, 38, 0.55);
  padding: 10px 16px;
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 0.3s steps(4), transform 0.3s steps(4);
}
.toast.show { opacity: 1; transform: translateY(0); }
.toast-who {
  font-family: "PingFang SC", "Microsoft YaHei", sans-serif;
  font-size: 11px;
  letter-spacing: 2px;
  color: var(--accent);
}
.toast-text {
  font-family: "PingFang SC", "Microsoft YaHei", sans-serif;
  font-size: 13px;
  line-height: 1.7;
  color: var(--ink);
}

/* ------------------------------------------------------------
   小镇控制台（左侧上帝面板）
   ------------------------------------------------------------ */
.console-btn {
  pointer-events: auto;
  position: absolute;
  left: 18px;
  bottom: 18px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--paper);
  color: var(--ink);
  border: none;
  cursor: pointer;
  padding: 9px 12px;
  font-family: "PingFang SC", "Microsoft YaHei", sans-serif;
  font-size: 12px;
  letter-spacing: 2px;
  box-shadow:
    0 0 0 2px var(--edge),
    4px 4px 0 rgba(11, 16, 38, 0.55);
  transition: transform 0.12s steps(2), background 0.12s;
}
.console-btn:hover {
  background: var(--paper-solid);
  transform: translate(-1px, -1px);
  box-shadow:
    0 0 0 2px var(--accent),
    5px 5px 0 rgba(11, 16, 38, 0.55);
}
.console-btn svg { display: block; }

.console-panel {
  pointer-events: auto;
  position: absolute;
  left: 18px;
  top: 74px;
  bottom: 64px;
  width: min(292px, calc(100vw - 36px));
  display: flex;
  flex-direction: column;
  background: var(--paper);
  box-shadow:
    0 0 0 2px var(--edge),
    6px 6px 0 rgba(11, 16, 38, 0.55);
  opacity: 0;
  visibility: hidden;
  transform: translateX(-14px);
  transition: opacity 0.18s steps(3), transform 0.18s steps(3), visibility 0.18s;
  z-index: 30;
}
.console-panel.open {
  opacity: 1;
  visibility: visible;
  transform: translateX(0);
}
.con-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  box-shadow: 0 2px 0 rgba(232, 240, 255, 0.25);
}
.con-title {
  font-family: "PingFang SC", "Microsoft YaHei", sans-serif;
  font-weight: 700;
  font-size: 14px;
  letter-spacing: 4px;
  color: var(--accent);
}
.con-close {
  background: none;
  border: none;
  color: var(--ink-dim);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  padding: 2px 6px;
}
.con-close:hover { color: var(--ink); }

.con-body {
  flex: 1;
  overflow-y: auto;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  scrollbar-width: thin;
  scrollbar-color: var(--ink-dim) transparent;
}
.con-sec { display: flex; flex-direction: column; gap: 7px; }
.con-label {
  font-family: "PingFang SC", "Microsoft YaHei", sans-serif;
  font-size: 12px;
  letter-spacing: 2px;
  color: var(--ink-dim);
}
.con-label b { color: var(--ink); font-weight: 700; }

/* 时间滑杆（像素风：方块轨道） */
.con-slider {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 10px;
  background: repeating-linear-gradient(90deg, #3f4360 0 6px, #2b3050 6px 8px);
  box-shadow: inset 0 0 0 2px rgba(232, 240, 255, 0.35);
  cursor: pointer;
}
.con-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px;
  height: 20px;
  background: var(--accent);
  box-shadow: 0 0 0 2px var(--edge);
  cursor: pointer;
}
.con-slider::-moz-range-thumb {
  width: 14px;
  height: 20px;
  border: none;
  border-radius: 0;
  background: var(--accent);
  box-shadow: 0 0 0 2px var(--edge);
  cursor: pointer;
}

/* 按钮组（倍速/季节/天气） */
.con-speed, .con-grid { display: flex; flex-wrap: wrap; gap: 5px; }
.con-speed button, .con-grid button {
  pointer-events: auto;
  background: rgba(232, 240, 255, 0.08);
  border: none;
  color: var(--ink);
  cursor: pointer;
  padding: 6px 10px;
  font-family: "PingFang SC", "Microsoft YaHei", sans-serif;
  font-size: 12px;
  letter-spacing: 1px;
  box-shadow: 0 0 0 2px rgba(232, 240, 255, 0.3);
  transition: background 0.1s;
}
.con-speed button:hover, .con-grid button:hover { background: rgba(255, 216, 138, 0.15); }
.con-speed button.on, .con-grid button.on {
  background: var(--accent);
  color: #16204a;
  box-shadow: 0 0 0 2px var(--edge);
}

/* 传送下拉 */
.con-teleport {
  pointer-events: auto;
  width: 100%;
  background: var(--paper-solid);
  border: none;
  color: var(--ink);
  padding: 7px 8px;
  font-family: "PingFang SC", "Microsoft YaHei", sans-serif;
  font-size: 12px;
  box-shadow: 0 0 0 2px rgba(232, 240, 255, 0.35);
}

/* 任务列表 */
.con-quests {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.con-quest {
  background: rgba(232, 240, 255, 0.06);
  box-shadow: inset 2px 0 0 var(--ink-dim);
  padding: 6px 8px;
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.con-quest.active { box-shadow: inset 2px 0 0 var(--accent); }
.con-quest.done { opacity: 0.55; box-shadow: inset 2px 0 0 var(--clothA, #7aad8a); }
.q-name {
  font-family: "PingFang SC", "Microsoft YaHei", sans-serif;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 2px;
  color: var(--ink);
}
.q-state { font-size: 11px; color: var(--accent); }
.con-quest.done .q-state { color: #7aad8a; }
.q-desc {
  font-size: 11px;
  line-height: 1.5;
  color: var(--ink-dim);
}

.con-stats {
  font-size: 11px;
  line-height: 1.7;
  color: var(--ink-dim);
  letter-spacing: 1px;
}

/* ------------------------------------------------------------
   小屏适配
   ------------------------------------------------------------ */
@media (max-width: 640px) {
  .hud-zh { font-size: 19px; letter-spacing: 6px; }
  .hud-en { font-size: 8px; }
  .hud-hints { font-size: 10px; }
  .plaque { bottom: 30px; padding: 11px 12px 8px; }
  .plaque-name { font-size: 15px; letter-spacing: 4px; }
  .boot-grid { grid-template-columns: repeat(8, 16px); grid-template-rows: repeat(5, 16px); }
  .guide { top: auto; bottom: 110px; max-height: 46vh; }
  .guide-btn, .reset-btn { font-size: 11px; padding: 7px 9px; }
  .guide-btn { bottom: 60px; }
  .console-panel { top: auto; bottom: 64px; max-height: 60vh; }
  .console-btn { font-size: 11px; padding: 7px 9px; }
  .toasts { bottom: 150px; }
}

/* ------------------------------------------------------------
   无障碍：用户偏好减动效时，动画全部退化为静态
   ------------------------------------------------------------ */
@media (prefers-reduced-motion: reduce) {
  .hud { animation: none; }
  .boot-title { animation: none; }
}
