/* ============================================================
   C’est la vie. · 像素冒险（V3）
   逻辑分辨率 160×320，tile 16。像素风 UI，不用外部素材。
   ============================================================ */

:root {
  --ink: #e8e4d8;
  --dim: #8a8f9a;
  --line: #3a4048;
  --panel: #171b22;
  --panel-2: #1f242c;
  --accent: #e8b83a;
  --red: #d8503e;
  --f-pixel: "PingFang SC", "Hiragino Sans GB", -apple-system, sans-serif;
  --f-serif: "Songti SC", "STSong", serif;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0; padding: 0; height: 100%;
  background: #0a0c10;
  overscroll-behavior: none;
}

body {
  font-family: var(--f-pixel);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
}

.app {
  position: relative;
  height: 100dvh;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  background:
    radial-gradient(80% 50% at 50% 0%, #1a2028 0%, #0a0c10 70%);
  overflow: hidden;
}

.console {
  position: relative;
  width: min(100vw, calc(100dvh * 0.5));
  height: min(100dvh, calc(100vw * 2));
  max-height: 100dvh;
  background: #0e1014;
  box-shadow: 0 0 0 1px #262c34, 0 12px 40px rgba(0,0,0,.6);
}

#cv {
  width: 100%; height: 100%;
  display: block;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

/* ---------------- HUD ---------------- */
.hud {
  position: absolute; left: 0; right: 0; top: 0;
  display: flex; align-items: center; gap: 8px;
  padding: 7px 9px;
  font-size: 8px; letter-spacing: .06em;
  pointer-events: none;
}
.hud-mark {
  font-family: var(--f-serif); font-size: 8px;
  color: rgba(232, 228, 216, .6);
}
.region {
  margin-left: auto;
  padding: 2px 7px;
  background: rgba(14, 16, 20, .72);
  border: 1px solid var(--line);
  color: var(--accent);
  font-size: 8px;
}
.found {
  padding: 2px 7px;
  background: rgba(14, 16, 20, .72);
  border: 1px solid var(--line);
  color: var(--dim);
  font-size: 8px;
}
.mus {
  pointer-events: auto;
  width: 22px; height: 22px;
  display: grid; place-items: center;
  background: rgba(14, 16, 20, .72);
  border: 1px solid var(--line);
  color: var(--dim);
  padding: 0;
}
.mus .slash { opacity: 1; }
.mus.is-playing { color: var(--accent); border-color: #6a5a2a; }
.mus.is-playing .slash { opacity: 0; }

/* ---------------- 交互提示 ---------------- */
.a-hint {
  position: absolute; left: 50%; bottom: 96px;
  transform: translateX(-50%);
  padding: 3px 9px;
  background: rgba(14, 16, 20, .9);
  border: 1px solid var(--accent);
  color: var(--accent);
  font-size: 8px; letter-spacing: .1em;
  animation: hintBob 1.4s ease-in-out infinite;
  pointer-events: none;
}
@keyframes hintBob {
  0%, 100% { transform: translate(-50%, 0); }
  50% { transform: translate(-50%, -3px); }
}

/* ---------------- 摇杆 ---------------- */
.pad {
  position: absolute; left: 12px; bottom: 16px;
  width: 84px; height: 84px;
  touch-action: none;
}
.pad-base {
  position: absolute; inset: 0;
  border-radius: 50%;
  background: rgba(22, 26, 32, .55);
  border: 1px solid rgba(120, 130, 145, .28);
}
.stick {
  position: absolute; left: 50%; top: 50%;
  width: 38px; height: 38px; margin: -19px 0 0 -19px;
  border-radius: 50%;
  background: rgba(150, 160, 175, .38);
  border: 1px solid rgba(190, 200, 215, .4);
  transition: transform .06s linear;
}

/* ---------------- A 键 ---------------- */
.a-btn {
  position: absolute; right: 14px; bottom: 22px;
  width: 58px; height: 58px;
  border-radius: 50%;
  background: rgba(40, 46, 56, .8);
  border: 2px solid rgba(200, 180, 120, .55);
  color: var(--accent);
  font-family: var(--f-serif); font-size: 18px;
  box-shadow: 0 3px 0 rgba(0,0,0,.5);
}
.a-btn:active { transform: translateY(2px); box-shadow: 0 1px 0 rgba(0,0,0,.5); }

/* ---------------- 对话框 ---------------- */
.console.dialog-on .pad,
.console.dialog-on .a-btn {
  opacity: 0; pointer-events: none;
}
.pad, .a-btn { transition: opacity .2s; }

.dialog {
  position: absolute; left: 8px; right: 8px; bottom: 8px;
  min-height: 74px;
  padding: 9px 11px 14px;
  background: var(--panel);
  border: 2px solid #4a525e;
  box-shadow: 0 0 0 2px #0e1014, 0 6px 18px rgba(0,0,0,.5);
  z-index: 20;
}
.dlg-name {
  font-size: 8px; letter-spacing: .1em;
  color: var(--accent);
  margin-bottom: 5px;
}
.dlg-text {
  font-family: var(--f-serif);
  font-size: 11px; line-height: 1.7;
  color: #ece8dc;
  min-height: 34px;
  white-space: pre-wrap;
}
.dlg-next {
  position: absolute; right: 9px; bottom: 4px;
  font-size: 8px; color: var(--accent);
  animation: blink 1s steps(2) infinite;
}
@keyframes blink { 50% { opacity: 0; } }

/* ---------------- 物品特写 ---------------- */
.item {
  position: absolute; inset: 0;
  z-index: 40;
  background: rgba(8, 10, 14, .82);
  display: flex; align-items: flex-end;
}
.item[hidden] { display: none; }
.item-panel {
  position: relative;
  width: 100%;
  max-height: 88%;
  overflow-y: auto;
  padding: 16px 14px 26px;
  background: var(--panel-2);
  border-top: 2px solid #4a525e;
  box-shadow: 0 -8px 26px rgba(0,0,0,.55);
  animation: itemUp .3s cubic-bezier(.2,.8,.2,1);
}
@keyframes itemUp { from { transform: translateY(40px); opacity: 0; } }
.item-close {
  position: absolute; right: 10px; top: 10px;
  width: 26px; height: 26px;
  background: #2a3038;
  border: 1px solid #4a525e;
  color: var(--dim);
  font-size: 15px; line-height: 1;
}
.item-kicker {
  font-size: 7.5px; letter-spacing: .14em;
  color: var(--dim);
  padding-right: 30px;
}
.item-title {
  margin: 6px 0 0;
  font-family: var(--f-serif); font-size: 16px; line-height: 1.4;
  color: #f2eee2;
  font-weight: 600;
}
.item-hook {
  margin: 6px 0 0;
  font-size: 9.5px; line-height: 1.65;
  color: #a8aeb8;
}
.item-body { margin-top: 12px; }
.item-foot {
  margin-top: 14px; padding-top: 9px;
  border-top: 1px dashed #3a4048;
  font-size: 7.5px; line-height: 1.6;
  color: #6f7682;
}

/* 特写内的聊天行 */
.px-chat {
  display: flex; align-items: baseline; gap: 6px;
  padding: 5px 0;
  border-bottom: 1px dotted #333a44;
  font-family: var(--f-serif); font-size: 11.5px; line-height: 1.55;
  color: #ddd8cc;
}
.px-who {
  flex: 0 0 auto;
  font-family: var(--f-pixel); font-size: 7.5px;
  padding: 1px 4px;
  background: #2f3a4a; color: #cfe0f0;
}
.px-chat.her .px-who { background: #4a2f3a; color: #f0d0dc; }
.px-chat.punch .px-txt { color: var(--accent); font-size: 13px; }
.px-at {
  flex: 0 0 auto;
  font-family: var(--f-pixel); font-size: 7px;
  color: #6f7682;
}
.px-note {
  margin: 9px 0 0;
  font-size: 8.5px; line-height: 1.7;
  color: #8a909a;
}
.px-img {
  width: 46%; margin: 2px auto 0;
  border: 3px solid #2a3038;
  background: #0e1014;
  display: block;
}

/* 特写内的小机关 */
.px-deck { position: relative; height: 96px; margin-top: 4px; }
.px-card {
  position: absolute; left: 0; right: 0; top: 0;
  height: 84px;
  background: #232a34;
  border: 1px solid #4a525e;
  padding: 8px 10px;
  font-size: 9px; line-height: 1.6;
  color: #cfd4dc;
  transition: transform .35s, opacity .3s;
}
.px-card.gone { transform: translateX(120%) rotate(12deg); opacity: 0; }
.px-tea {
  display: flex; flex-direction: column; align-items: center;
  padding: 8px 0; cursor: pointer;
}
.px-cup {
  width: 44px; height: 60px;
  background: #e8c4d4;
  border: 2px solid #f6dfe8;
  position: relative;
}
.px-cup::after {
  content: ""; position: absolute; left: 6px; right: 6px; bottom: 8px; height: 14px;
  background: repeating-linear-gradient(180deg, #b08a9a 0 2px, transparent 2px 4px);
}
.px-count {
  margin-top: 6px; font-size: 8px; color: var(--dim);
}
.px-reveal {
  margin-top: 8px; text-align: center;
  font-family: var(--f-serif); font-size: 13px; color: var(--accent);
}
.px-strip {
  padding: 10px;
  background: #2a3038;
  border: 1px solid #4a525e;
  font-family: var(--f-serif); font-size: 12px; line-height: 1.6;
  color: #ece8dc;
  min-height: 46px;
}
.px-btn {
  margin-top: 8px;
  padding: 6px 14px;
  background: #2a3038;
  border: 1px solid #5a6270;
  color: var(--accent);
  font-size: 9px; letter-spacing: .06em;
}
.px-scratch {
  position: relative; height: 74px;
  border: 1px solid #4a525e;
  background: #232a34;
  display: grid; place-items: center;
  cursor: pointer;
}
.px-scratch b { font-family: var(--f-serif); font-size: 16px; color: var(--accent); }
.px-scratch .cover {
  position: absolute; inset: 0;
  display: grid; place-items: center;
  background: repeating-linear-gradient(135deg, #4a5058 0 5px, #3e444c 5px 10px);
  color: #9aa0aa; font-size: 8px;
  transition: opacity .3s;
}
.px-notes { display: flex; gap: 4px; }
.px-note-btn {
  flex: 1 1 0; height: 34px;
  background: #2a3038; border: 1px solid #4a525e;
  color: #cfd4dc; font-size: 8px;
}
.px-note-btn.on { background: #4a4222; color: var(--accent); }
.px-env {
  position: relative; height: 120px; cursor: pointer;
}
.px-env .letter {
  position: absolute; left: 0; right: 0; top: 0;
  padding: 10px;
  background: #ece8dc; color: #1a1e24;
  font-family: var(--f-serif); font-size: 10.5px; line-height: 1.6;
  opacity: 0; transform: translateY(20px);
  transition: all .4s;
  z-index: 1;
}
.px-env.open .letter { opacity: 1; transform: translateY(0); }
.px-env .env {
  position: absolute; left: 0; right: 0; bottom: 0; height: 76px;
  background: #2a3038; border: 1px solid #5a6270;
  display: grid; place-items: center;
  color: var(--dim); font-size: 8px;
  z-index: 2;
  transition: all .4s;
}
.px-env.open .env { opacity: 0; transform: translateY(30px); }
.px-gap {
  margin-top: 10px; padding: 9px 10px;
  border-left: 2px solid var(--red);
  background: rgba(216, 80, 62, .08);
  font-size: 8px; line-height: 1.7;
  color: #b8bec8;
}
.px-gap b { display: block; color: var(--red); font-size: 9.5px; margin-bottom: 4px; }
.px-next {
  display: block; width: 100%; margin-top: 10px;
  padding: 8px 10px;
  background: #232a34; border: 1px dashed #4a525e;
  color: var(--accent); font-size: 8.5px; text-align: left;
}

/* 外部提示 */
.outside-hint {
  position: absolute; left: 0; right: 0; bottom: 3px;
  margin: 0;
  text-align: center;
  font-size: 7.5px; letter-spacing: .08em;
  color: rgba(138, 143, 154, .5);
  pointer-events: none;
}

@media (prefers-reduced-motion: reduce) {
  .a-hint, .dlg-next { animation: none; }
  .item-panel { animation: none; }
}
