:root {
  --accent: #ffb648;
  --accent-deep: #ff8a2a;
  --panel: rgba(14, 16, 22, 0.82);
  --panel-border: rgba(255, 182, 72, 0.35);
  --text: #f4efe6;
  --text-dim: #c9c2b4;
  --danger: #ff5d5d;
  --ok: #67e08a;
}

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

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #06070a;
  font-family: "PingFang SC", "Microsoft YaHei", -apple-system, "Segoe UI", sans-serif;
  color: var(--text);
  user-select: none;
  -webkit-user-select: none;
}

#game-container {
  position: fixed;
  inset: 0;
}

#game-container canvas {
  display: block;
}

.hidden {
  display: none !important;
}

/* 准星 */
#crosshair {
  position: fixed;
  top: 50%;
  left: 50%;
  width: 6px;
  height: 6px;
  margin: -3px 0 0 -3px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: 0 0 8px rgba(255, 255, 255, 0.7);
  pointer-events: none;
  z-index: 10;
}

/* 交互对象名称 */
#interact-label {
  position: fixed;
  top: 58%;
  left: 50%;
  transform: translateX(-50%);
  padding: 6px 14px;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 20px;
  font-size: 15px;
  color: var(--accent);
  pointer-events: none;
  z-index: 10;
  white-space: nowrap;
}

/* 顶部 HUD（仅目标） */
#top-hud {
  position: fixed;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  z-index: 12;
  pointer-events: none;
}

/* 底部 HUD（提示 + 字幕 + 背包 + 操作说明，纵向堆叠不重叠） */
#bottom-hud {
  position: fixed;
  bottom: 14px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  z-index: 12;
  pointer-events: none;
}

/* 目标栏 */
#objective-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 16px;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 10px;
  backdrop-filter: blur(6px);
  max-width: 70vw;
}

.objective-tag {
  color: var(--accent-deep);
  font-weight: 700;
  letter-spacing: 2px;
  white-space: nowrap;
}

#objective-text {
  color: var(--text-dim);
  font-size: 14px;
}

/* 字幕 */
#message {
  max-width: 60vw;
  padding: 12px 22px;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 12px;
  backdrop-filter: blur(6px);
  font-size: 16px;
  line-height: 1.6;
  text-align: center;
}

#hint {
  max-width: 56vw;
  padding: 8px 16px;
  background: rgba(60, 70, 30, 0.85);
  border: 1px solid rgba(200, 220, 120, 0.4);
  border-radius: 10px;
  color: #eef0c8;
  font-size: 14px;
  text-align: center;
}

/* 背包 */
#inventory-bar {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  pointer-events: auto;
}

.inv-title {
  font-size: 12px;
  letter-spacing: 2px;
  color: var(--text-dim);
}

#inventory-items {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: center;
}

.inv-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  width: 66px;
  padding: 8px 6px;
  background: var(--panel);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 10px;
  cursor: pointer;
  transition: transform 0.12s ease, border-color 0.12s ease, background 0.12s ease;
}

.inv-item:hover {
  transform: translateY(-3px);
}

.inv-item.selected {
  border-color: var(--accent);
  background: rgba(255, 182, 72, 0.16);
  box-shadow: 0 0 12px rgba(255, 182, 72, 0.4);
}

.inv-item .inv-dot {
  width: 22px;
  height: 22px;
  border-radius: 6px;
  box-shadow: inset 0 0 0 2px rgba(0, 0, 0, 0.2);
}

.inv-item .inv-name {
  font-size: 12px;
  color: var(--text);
  text-align: center;
  line-height: 1.2;
}

#selected-tip {
  font-size: 13px;
  color: var(--accent);
  background: rgba(255, 182, 72, 0.12);
  border: 1px solid var(--panel-border);
  padding: 6px 12px;
  border-radius: 8px;
}

/* 操作说明 */
#controls-help {
  font-size: 12px;
  color: rgba(255, 255, 255, 0.4);
  white-space: nowrap;
}

/* 弹窗（密码锁） */
.modal {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.5);
  z-index: 20;
}

.keypad-card {
  width: 320px;
  padding: 24px;
  background: #151820;
  border: 1px solid var(--panel-border);
  border-radius: 16px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6);
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.keypad-title {
  text-align: center;
  font-size: 18px;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: 2px;
}

.keypad-display {
  height: 54px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  letter-spacing: 10px;
  background: #0b0d12;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 10px;
  color: var(--accent);
}

.keypad-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.keypad-grid button {
  height: 52px;
  font-size: 20px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: #1e222d;
  color: var(--text);
  border-radius: 10px;
  cursor: pointer;
  transition: background 0.1s ease;
}

.keypad-grid button:hover {
  background: #2b303d;
}

.keypad-grid button:active {
  background: #383f4f;
}

.keypad-actions {
  display: flex;
  gap: 10px;
}

/* 通用按钮 */
.btn {
  flex: 1;
  padding: 12px;
  border: none;
  border-radius: 10px;
  font-size: 15px;
  cursor: pointer;
  letter-spacing: 1px;
  transition: transform 0.1s ease, filter 0.1s ease;
}

.btn:active {
  transform: scale(0.97);
}

.btn-primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-deep));
  color: #231400;
  font-weight: 700;
}

.btn-primary:hover {
  filter: brightness(1.08);
}

.btn-ghost {
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: var(--text-dim);
}

.btn-ghost:hover {
  background: rgba(255, 255, 255, 0.06);
}

/* 遮罩层（标题/关卡/结局） */
.overlay {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(circle at 50% 40%, rgba(20, 22, 30, 0.9), rgba(4, 5, 8, 0.96));
  z-index: 30;
}

.overlay-card {
  width: min(560px, 88vw);
  padding: 44px 40px;
  background: rgba(15, 17, 24, 0.85);
  border: 1px solid var(--panel-border);
  border-radius: 20px;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.7);
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.overlay-tag {
  font-size: 13px;
  letter-spacing: 4px;
  color: var(--accent-deep);
  text-transform: uppercase;
}

.overlay-card h1 {
  font-size: 34px;
  color: var(--text);
  letter-spacing: 3px;
}

.overlay-card p {
  font-size: 16px;
  line-height: 1.9;
  color: var(--text-dim);
  text-align: left;
  white-space: pre-line;
}

.overlay-card .btn {
  margin-top: 8px;
}
