/* ============================================================
 * BLOCKROOMS - style.css
 * MC 风格 UI × 后室配色
 * ============================================================ */
* { margin: 0; padding: 0; box-sizing: border-box; user-select: none; }
:root {
  --bk-yellow: #d6c576;
  --bk-yellow-dark: #8b7d46;
  --bk-panel: rgba(24, 20, 10, 0.92);
  --bk-border: #6e5631;
}
html, body { width: 100%; height: 100%; overflow: hidden; background: #000; }
body {
  font-family: 'Microsoft YaHei', 'PingFang SC', sans-serif;
  color: #e8e0c0;
  cursor: default;
}
img, .slot-inner { image-rendering: pixelated; }
canvas#game-canvas { position: fixed; inset: 0; display: block; }

/* ================= 载入 ================= */
#loading {
  position: fixed; inset: 0; z-index: 100;
  background: #0a0905;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 22px; transition: opacity .6s;
}
#loading.hidden { opacity: 0; pointer-events: none; }
.load-block { animation: loadspin 1.6s ease-in-out infinite; }
@keyframes loadspin {
  0% { transform: rotate(0deg) scale(1); }
  50% { transform: rotate(180deg) scale(0.85); }
  100% { transform: rotate(360deg) scale(1); }
}
.load-text { color: var(--bk-yellow); letter-spacing: 4px; font-size: 15px; animation: pulse 1.2s infinite; }
@keyframes pulse { 50% { opacity: 0.4; } }

/* ================= 通用屏幕 ================= */
.screen { position: fixed; inset: 0; display: none; z-index: 10; }
.screen.active { display: block; }
.menu-dim {
  position: absolute; inset: 0;
  background: radial-gradient(ellipse at 50% 40%, rgba(10,8,2,0.45), rgba(5,4,1,0.82));
  backdrop-filter: blur(2px);
}
.menu-dim.dark { background: rgba(0, 0, 0, 0.72); backdrop-filter: blur(3px); }

/* ================= 主菜单 ================= */
#menu-main .menu-content {
  position: relative; height: 100%;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 8px;
}
.logo-wrap { position: relative; text-align: center; margin-bottom: 26px; animation: logoin 1.2s cubic-bezier(.2,1.4,.4,1); }
@keyframes logoin { from { transform: translateY(-60px) scale(0.8); opacity: 0; } }
.logo {
  font-size: 92px; font-weight: 900; letter-spacing: 10px;
  color: #e8d88a; position: relative; line-height: 1.1;
  text-shadow:
    3px 3px 0 #8b7d46, 6px 6px 0 #4a3f1e,
    9px 9px 0 #241f0c, 12px 12px 24px rgba(0,0,0,0.8);
  animation: logofloat 5s ease-in-out infinite;
}
.logo::before {
  content: attr(data-text);
  position: absolute; inset: 0;
  background: repeating-linear-gradient(0deg, transparent 0 3px, rgba(0,0,0,0.14) 3px 4px);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
@keyframes logofloat { 50% { transform: translateY(-6px); } }
.logo-sub {
  margin-top: 10px; font-size: 18px; letter-spacing: 14px; color: #b8a95e;
  text-shadow: 2px 2px 0 #241f0c;
}
.splash {
  position: absolute; right: -70px; top: 8px;
  color: #ffe95e; font-size: 17px; font-weight: bold;
  transform: rotate(-16deg);
  text-shadow: 2px 2px 0 #3f3600;
  animation: splashpulse 0.5s ease-in-out infinite alternate;
  pointer-events: none;
}
@keyframes splashpulse { from { transform: rotate(-16deg) scale(1); } to { transform: rotate(-16deg) scale(1.08); } }
.menu-buttons { display: flex; flex-direction: column; gap: 12px; width: 340px; }
.menu-footer {
  position: absolute; bottom: 16px; left: 0; right: 0;
  display: flex; justify-content: space-between; padding: 0 20px;
  font-size: 12px; color: rgba(214, 197, 118, 0.5);
  text-shadow: 1px 1px 0 #000;
}

/* ---- MC 按钮 ---- */
.mc-btn {
  position: relative;
  font-family: inherit; font-size: 16px; font-weight: bold; letter-spacing: 2px;
  color: #f0ead0; padding: 11px 18px; width: 100%;
  background: linear-gradient(#7a7159, #5d553f 45%, #4a4330);
  border: 2px solid #1a160c;
  box-shadow:
    inset 0 2px 0 rgba(255, 250, 220, 0.28),
    inset 0 -3px 0 rgba(0, 0, 0, 0.4),
    0 3px 0 #0c0a05, 0 5px 8px rgba(0,0,0,0.5);
  cursor: pointer;
  text-shadow: 2px 2px 0 rgba(0,0,0,0.6);
  transition: transform .06s, filter .1s;
}
.mc-btn:hover {
  filter: brightness(1.18);
  outline: 2px solid rgba(232, 216, 138, 0.8);
  outline-offset: -2px;
}
.mc-btn:active { transform: translateY(2px); box-shadow: inset 0 2px 0 rgba(0,0,0,0.3), 0 1px 0 #0c0a05; }
.mc-btn.big { font-size: 19px; padding: 14px 18px; }

/* ================= 面板（设置/暂停） ================= */
.panel-box {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
  width: 460px; max-width: 92vw;
  background: var(--bk-panel);
  border: 2px solid var(--bk-border);
  box-shadow: 0 0 0 2px #14100a, inset 0 0 40px rgba(0,0,0,0.5), 0 20px 60px rgba(0,0,0,0.8);
  padding: 26px 30px;
  display: flex; flex-direction: column; gap: 13px;
  animation: panelin .22s cubic-bezier(.2,1.4,.4,1);
}
@keyframes panelin { from { transform: translate(-50%, -46%) scale(0.92); opacity: 0; } }
.panel-title {
  text-align: center; font-size: 24px; font-weight: 900; letter-spacing: 8px;
  color: var(--bk-yellow); text-shadow: 2px 2px 0 #241f0c;
  margin-bottom: 8px;
}
.set-row { display: flex; align-items: center; gap: 12px; font-size: 14px; }
.set-row label { width: 90px; color: #cfc394; }
.set-row span { width: 56px; text-align: right; color: #fff; font-weight: bold; }
.set-row input[type=range] {
  flex: 1; appearance: none; height: 8px;
  background: #14100a; border: 1px solid var(--bk-border); outline: none;
}
.set-row input[type=range]::-webkit-slider-thumb {
  appearance: none; width: 16px; height: 20px;
  background: linear-gradient(#e8d88a, #b09c50);
  border: 2px solid #14100a; cursor: pointer;
}

.panel-center {
  position: relative; height: 100%;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 14px;
}
.panel-center .mc-btn { width: 320px; }

/* ================= 死亡 ================= */
.death-dim { position: absolute; inset: 0; background: rgba(96, 8, 8, 0.55); backdrop-filter: blur(1px); animation: deathin 1s; }
@keyframes deathin { from { opacity: 0; } }
.death-title {
  font-size: 72px; font-weight: 900; letter-spacing: 10px; color: #fff;
  text-shadow: 4px 4px 0 #4a0505, 8px 8px 20px rgba(0,0,0,0.9);
  animation: deathtitle 0.9s cubic-bezier(.2,1.6,.4,1);
}
@keyframes deathtitle { from { transform: scale(3); opacity: 0; } }
.death-reason { font-size: 17px; color: #ffd9d0; margin-bottom: 18px; text-shadow: 2px 2px 0 #000; }

/* ================= 胜利 ================= */
.win-exit { animation: winglow 2s ease-in-out infinite; }
@keyframes winglow { 50% { filter: drop-shadow(0 0 26px #54d98c); } }
.win-title { font-size: 44px; font-weight: 900; letter-spacing: 6px; color: #d2ffe4; text-shadow: 3px 3px 0 #0b3d20; }
.win-sub { color: #9fd8b4; font-size: 15px; margin-bottom: 12px; text-shadow: 1px 1px 0 #000; }
#win-stats {
  display: flex; gap: 26px; margin: 8px 0 18px;
  background: rgba(6, 20, 12, 0.7); border: 2px solid #1c7d44;
  padding: 14px 26px;
}
#win-stats div { display: flex; flex-direction: column; align-items: center; gap: 4px; }
#win-stats span { font-size: 12px; color: #7fbc96; }
#win-stats b { font-size: 22px; color: #fff; }

/* ================= 开场字幕 ================= */
#screen-intro { background: #030302; z-index: 40; }
#intro-text {
  position: absolute; left: 50%; top: 44%; transform: translate(-50%, -50%);
  width: min(720px, 88vw); text-align: center;
}
.intro-line {
  font-size: 22px; line-height: 2.2; color: #cfc394; letter-spacing: 3px;
  text-shadow: 0 0 14px rgba(214, 197, 118, 0.3), 2px 2px 0 #000;
  min-height: 48px;
}
#intro-skip {
  position: absolute; right: 28px; bottom: 24px;
  background: none; border: 1px solid #55511f; color: #8b8446;
  font-family: inherit; font-size: 14px; padding: 8px 18px; cursor: pointer;
  letter-spacing: 2px;
}
#intro-skip:hover { color: #e8d88a; border-color: #e8d88a; }

/* ================= HUD ================= */
#hud { pointer-events: none; z-index: 5; }
#crosshair {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
  mix-blend-mode: difference; opacity: 0.9;
}
#hud-bottom {
  position: absolute; bottom: 10px; left: 50%; transform: translateX(-50%);
  display: flex; flex-direction: column; align-items: center; gap: 5px;
}
#status-bars { display: flex; justify-content: space-between; width: 432px; }
#hearts, #sanity { display: flex; gap: 1px; }
.stat-icon { width: 18px; height: 18px; filter: drop-shadow(1px 1px 0 rgba(0,0,0,0.8)); }
.stat-icon.shake { animation: hshake 0.5s infinite; }
@keyframes hshake {
  0%, 100% { transform: translateY(0); }
  25% { transform: translateY(-2px); }
  75% { transform: translateY(1px); }
}
#hotbar { display: flex; }
.hb-slot {
  width: 48px; height: 48px; position: relative;
  background: rgba(12, 10, 5, 0.72);
  border: 2px solid;
  border-color: #14100a #5c5338 #5c5338 #14100a;
  box-shadow: inset 0 0 8px rgba(0,0,0,0.6);
}
.hb-slot.selected {
  border: 2px solid #f0ead0;
  outline: 2px solid #14100a;
  transform: scale(1.12);
  z-index: 2;
  background: rgba(30, 26, 12, 0.85);
}
.slot-inner {
  position: absolute; inset: 4px;
  background-size: contain; background-repeat: no-repeat; background-position: center;
}
.slot-count {
  position: absolute; right: 2px; bottom: 0;
  font-size: 13px; font-weight: bold; color: #fff;
  text-shadow: 1px 1px 0 #000, -1px 1px 0 #000, 1px -1px 0 #000;
}
#item-name {
  min-height: 20px; font-size: 15px; font-weight: bold; color: #f0ead0;
  text-shadow: 2px 2px 0 rgba(0,0,0,0.8);
  opacity: 0; transition: opacity .4s;
}
#item-name.show { opacity: 1; }
#hint {
  min-height: 18px; font-size: 13px; color: rgba(232, 224, 192, 0.85);
  text-shadow: 1px 1px 0 #000; letter-spacing: 1px;
}

/* ---- 任务目标 ---- */
#objective {
  position: absolute; left: 16px; top: 16px;
  background: linear-gradient(rgba(24, 20, 10, 0.88), rgba(18, 15, 7, 0.88));
  border: 2px solid var(--bk-border);
  border-left: 4px solid var(--bk-yellow);
  padding: 10px 16px 12px; max-width: 320px;
  opacity: 0; transform: translateX(-20px);
  transition: all .4s cubic-bezier(.2,1.2,.4,1);
  box-shadow: 0 4px 16px rgba(0,0,0,0.5);
}
#objective.show { opacity: 1; transform: none; }
.obj-tag { font-size: 11px; color: var(--bk-yellow); letter-spacing: 3px; margin-bottom: 4px; }
.obj-title { font-size: 16px; font-weight: bold; color: #fff; text-shadow: 1px 1px 0 #000; }
.obj-desc { font-size: 12px; color: #b8ad85; margin-top: 4px; line-height: 1.6; }

/* ---- 关卡标题 ---- */
#level-title {
  position: absolute; left: 0; right: 0; top: 26%;
  text-align: center; opacity: 0; pointer-events: none;
}
#level-title.show { animation: lvtitle 4.5s ease forwards; }
@keyframes lvtitle {
  0% { opacity: 0; transform: translateY(18px); }
  12% { opacity: 1; transform: none; }
  80% { opacity: 1; }
  100% { opacity: 0; }
}
.lt-name {
  font-size: 58px; font-weight: 900; letter-spacing: 16px; color: #e8d88a;
  text-shadow: 3px 3px 0 #241f0c, 0 0 40px rgba(232, 216, 138, 0.4);
}
.lt-sub { font-size: 18px; color: #b8a95e; letter-spacing: 6px; margin-top: 6px; text-shadow: 2px 2px 0 #000; }

/* ---- 通知 ---- */
#toasts {
  position: absolute; left: 16px; bottom: 90px;
  display: flex; flex-direction: column; gap: 6px;
}
.toast {
  display: flex; align-items: center; gap: 8px;
  background: rgba(18, 15, 7, 0.88);
  border: 1px solid var(--bk-border);
  padding: 7px 14px; font-size: 13px;
  opacity: 0; transform: translateX(-30px);
  transition: all .35s cubic-bezier(.2,1.2,.4,1);
  text-shadow: 1px 1px 0 #000;
}
.toast.in { opacity: 1; transform: none; }
.toast img { width: 22px; height: 22px; }
.toast.quest { border-color: #1c7d44; color: #b6ffd2; }
.toast.pickup { color: #e8e0c0; }

/* ================= 覆盖特效 ================= */
.overlay { position: fixed; inset: 0; pointer-events: none; z-index: 8; }
#vignette-sanity {
  opacity: 0;
  background: radial-gradient(ellipse at center, transparent 30%, rgba(20, 2, 30, 0.55) 75%, rgba(8, 0, 14, 0.95) 100%);
  transition: opacity .5s;
}
#vignette-damage {
  opacity: 0;
  background: radial-gradient(ellipse at center, transparent 40%, rgba(120, 0, 0, 0.5) 85%, rgba(80, 0, 0, 0.9) 100%);
  transition: opacity .5s;
  animation: dmgpulse 1s infinite;
}
@keyframes dmgpulse { 50% { filter: brightness(1.35); } }
#flash-red { background: rgba(190, 20, 10, 0.45); opacity: 0; }
#flash-red.on { animation: redflash 0.45s ease-out; }
@keyframes redflash { 0% { opacity: 1; } 100% { opacity: 0; } }

/* ---- 故障效果 ---- */
#glitch-overlay { display: none; opacity: 0; overflow: hidden; }
.g-bars {
  position: absolute; inset: -10%;
  background: repeating-linear-gradient(0deg,
    transparent 0 26px, rgba(57, 255, 20, 0.09) 26px 28px,
    transparent 28px 60px, rgba(255, 0, 224, 0.08) 60px 62px);
  animation: gbars 0.7s steps(6) infinite;
}
.g-bars.g2 {
  background: repeating-linear-gradient(0deg,
    transparent 0 44px, rgba(0, 240, 255, 0.07) 44px 47px);
  animation-duration: 0.45s; animation-direction: reverse;
}
@keyframes gbars {
  0% { transform: translateY(0); }
  100% { transform: translateY(60px); }
}
.g-scan {
  position: absolute; inset: 0;
  background: repeating-linear-gradient(0deg, rgba(0,0,0,0.16) 0 2px, transparent 2px 4px);
}

/* ---- noclip 转场 ---- */
#noclip-overlay { position: fixed; inset: 0; z-index: 30; pointer-events: none; visibility: hidden; overflow: hidden; background: transparent; }
#noclip-overlay.active { visibility: visible; pointer-events: all; }
.nc-bars {
  position: absolute; inset: -20%;
  background: repeating-linear-gradient(90deg,
    rgba(5, 5, 8, 0.9) 0 8vw, rgba(57, 255, 20, 0.25) 8vw calc(8vw + 3px),
    rgba(8, 5, 10, 0.92) calc(8vw + 3px) 16vw, rgba(255, 0, 224, 0.22) 16vw calc(16vw + 2px));
  opacity: 0;
}
#noclip-overlay.active .nc-bars { animation: ncbars 2.6s steps(12) forwards; }
.nc-bars.n2 {
  background: repeating-linear-gradient(0deg,
    rgba(2, 2, 4, 0.85) 0 12vh, rgba(0, 240, 255, 0.2) 12vh calc(12vh + 3px));
}
#noclip-overlay.active .nc-bars.n2 { animation: ncbars2 2.6s steps(9) forwards; }
@keyframes ncbars {
  0% { opacity: 0; transform: translateX(0) skewX(0); }
  8% { opacity: 1; }
  50% { opacity: 1; transform: translateX(-6vw) skewX(-8deg); }
  90% { opacity: 1; }
  100% { opacity: 0; transform: translateX(-12vw); }
}
@keyframes ncbars2 {
  0% { opacity: 0; transform: translateY(0); }
  12% { opacity: 0.9; }
  55% { transform: translateY(8vh); }
  90% { opacity: 0.9; }
  100% { opacity: 0; transform: translateY(16vh); }
}
.nc-text {
  position: absolute; left: 50%; top: 46%; transform: translate(-50%, -50%);
  font-size: 64px; font-weight: 900; letter-spacing: 22px; color: #39ff14;
  text-shadow: 4px 0 0 #ff00e0, -4px 0 0 #00f0ff, 0 0 40px rgba(57, 255, 20, 0.5);
  opacity: 0; text-align: center;
}
.nc-text span { display: block; font-size: 16px; letter-spacing: 8px; color: #9be8ff; margin-top: 14px; text-shadow: 2px 0 0 #ff00e0; }
#noclip-overlay.active .nc-text { animation: nctext 2.6s steps(8) forwards; }
@keyframes nctext {
  0% { opacity: 0; transform: translate(-50%, -50%) scale(1.3); }
  15% { opacity: 1; transform: translate(-52%, -50%) scale(1); }
  30% { transform: translate(-48%, -51%); }
  45% { transform: translate(-51%, -49%); }
  70% { opacity: 1; }
  85% { opacity: 0; }
  100% { opacity: 0; }
}
.nc-white { position: absolute; inset: 0; background: #050508; opacity: 0; }
#noclip-overlay.active .nc-white { animation: ncwhite 2.6s forwards; }
@keyframes ncwhite {
  0% { opacity: 0; }
  45% { opacity: 0; }
  54% { opacity: 1; }
  62% { opacity: 1; }
  100% { opacity: 0; }
}

#fade-overlay {
  position: fixed; inset: 0; background: #000; z-index: 35;
  opacity: 0; pointer-events: none;
  transition: opacity .6s ease;
}

/* ================= 背包 / 合成 ================= */
#inventory-screen {
  position: fixed; inset: 0; z-index: 20; display: none;
  background: rgba(0, 0, 0, 0.55);
  align-items: center; justify-content: center;
}
#inventory-screen.open { display: flex; }
.inv-panel {
  display: flex; gap: 0;
  background: var(--bk-panel);
  border: 2px solid var(--bk-border);
  box-shadow: 0 0 0 2px #14100a, 0 24px 80px rgba(0,0,0,0.85);
  animation: invin .18s cubic-bezier(.2,1.4,.4,1);
  transform-origin: center;
  position: static;
}
@keyframes invin { from { transform: scale(0.94); opacity: 0; } }
.inv-left { padding: 20px 22px; border-right: 2px solid var(--bk-border); }
.inv-right { padding: 20px 22px; width: 330px; display: flex; flex-direction: column; }
.inv-header {
  font-size: 19px; font-weight: 900; letter-spacing: 4px; color: var(--bk-yellow);
  text-shadow: 2px 2px 0 #14100a; margin-bottom: 12px;
}
.inv-section-label { font-size: 11px; color: #8b8055; letter-spacing: 2px; margin: 8px 0 4px; }
#inv-grid { display: grid; grid-template-columns: repeat(9, 46px); }
#inv-hotbar { display: grid; grid-template-columns: repeat(9, 46px); }
.inv-slot {
  width: 46px; height: 46px; position: relative;
  background: rgba(10, 8, 4, 0.85);
  border: 1px solid;
  border-color: #0a0803 #4a4128 #4a4128 #0a0803;
  cursor: pointer;
}
.inv-slot:hover { background: rgba(60, 52, 24, 0.9); }
.inv-tip { margin-top: 12px; font-size: 11px; color: #7a7048; letter-spacing: 1px; }

#recipe-list { overflow-y: auto; max-height: 420px; display: flex; flex-direction: column; gap: 6px; padding-right: 4px; }
#recipe-list::-webkit-scrollbar { width: 8px; }
#recipe-list::-webkit-scrollbar-track { background: #14100a; }
#recipe-list::-webkit-scrollbar-thumb { background: var(--bk-border); }
.recipe {
  display: flex; align-items: center; gap: 10px;
  background: rgba(10, 8, 4, 0.7);
  border: 1px solid #3a331e;
  padding: 8px 10px;
  opacity: 0.55;
}
.recipe.can { opacity: 1; border-color: var(--bk-yellow-dark); }
.recipe.can:hover { background: rgba(50, 43, 20, 0.8); }
.recipe.locked { opacity: 0.4; }
.r-icon { width: 34px; height: 34px; }
.r-info { flex: 1; }
.r-name { font-size: 13px; font-weight: bold; color: #f0ead0; }
.r-name em { font-style: normal; font-size: 10px; color: #c77; }
.r-cost { display: flex; gap: 8px; margin-top: 3px; }
.cost { display: flex; align-items: center; gap: 3px; font-size: 11px; color: #b06a5a; }
.cost.ok { color: #9dc282; }
.cost img { width: 15px; height: 15px; }
.r-btn {
  font-family: inherit; font-size: 12px; font-weight: bold;
  padding: 6px 12px; cursor: pointer;
  background: linear-gradient(#6a613f, #4a4330);
  color: #f0ead0; border: 1px solid #14100a;
  box-shadow: inset 0 1px 0 rgba(255, 250, 220, 0.25);
}
.r-btn:hover:not(:disabled) { filter: brightness(1.25); }
.r-btn:disabled { opacity: 0.35; cursor: not-allowed; }

#cursor-item {
  position: fixed; z-index: 25; width: 40px; height: 40px;
  pointer-events: none; display: none;
  transform: translate(-50%, -50%);
}
#cursor-item .slot-inner { inset: 0; }
#cursor-item .slot-count { font-size: 14px; }

#tooltip {
  position: fixed; z-index: 26; display: none;
  background: rgba(14, 8, 24, 0.94);
  border: 2px solid #4a2d7a;
  padding: 8px 12px; max-width: 230px;
  pointer-events: none;
  box-shadow: 0 6px 20px rgba(0,0,0,0.7);
}
#tooltip b { color: #fff; font-size: 14px; display: block; }
#tooltip span { color: #a99add; font-size: 11px; line-height: 1.5; display: block; margin-top: 3px; }
