/* ============================================================
 * 我的世界 · 网页版  —  界面样式
 * ============================================================ */
* { margin: 0; padding: 0; box-sizing: border-box; }

html, body {
  width: 100%; height: 100%;
  overflow: hidden;
  background: #101418;
  color: #e8eef2;
  font-family: "Segoe UI", "Microsoft YaHei", system-ui, sans-serif;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

#app { position: fixed; inset: 0; }
#game { display: block; width: 100%; height: 100%; cursor: crosshair; }
.hidden { display: none !important; }

/* ---------------- HUD ---------------- */
#hud { position: absolute; inset: 0; pointer-events: none; }

#crosshair {
  position: absolute; left: 50%; top: 50%;
  width: 20px; height: 20px; margin: -10px 0 0 -10px;
  opacity: .9;
  transition: opacity .12s;
  background:
    linear-gradient(#fff, #fff) center / 2px 20px no-repeat,
    linear-gradient(#fff, #fff) center / 20px 2px no-repeat;
  mix-blend-mode: difference;
}
/* 没对准可挖的方块（超出 6 格或对着空气）→ 准星变暗 */
#crosshair.no-target { opacity: .32; }

#lockhint {
  position: absolute; left: 50%; top: 33%; transform: translateX(-50%);
  max-width: 78vw; text-align: center;
  font-size: 13px; line-height: 1.5;
  padding: 7px 14px; border-radius: 14px;
  background: rgba(0, 0, 0, .55);
  border: 1px solid rgba(255, 255, 255, .18);
  color: #e8eef2;
  text-shadow: 0 1px 3px #000;
  animation: lockHintDim .8s ease 15s forwards;  /* 15 秒后变淡，别挡视线 */
}
@keyframes lockHintDim { to { opacity: .38; } }
#lockhint.warn {
  background: rgba(120, 60, 0, .62);
  border-color: #ffb454;
  color: #ffe6c0;
}
/* #hud 是 pointer-events:none，链接要单独打开点击，否则点不到 */
#lockhint a {
  display: block;
  margin-top: 6px;
  pointer-events: auto;
  color: #ffe9b0;
  font-weight: 600;
  text-decoration: underline;
  cursor: pointer;
}
#lockhint a:hover { color: #fff; }

#debug {
  position: absolute; left: 10px; top: 10px;
  font: 12px/1.55 Consolas, "Courier New", monospace;
  background: rgba(0, 0, 0, .45);
  padding: 8px 10px; border-radius: 4px;
  white-space: pre;
  text-shadow: 0 1px 0 #000;
}

#toast {
  position: absolute; left: 50%; bottom: 110px; transform: translateX(-50%);
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  font-size: 14px; text-shadow: 0 2px 4px #000;
}
#toast div {
  background: rgba(0, 0, 0, .5); padding: 4px 12px; border-radius: 12px;
  animation: fadeUp 2.4s ease forwards;
}
@keyframes fadeUp {
  0% { opacity: 0; transform: translateY(8px); }
  12% { opacity: 1; transform: translateY(0); }
  75% { opacity: 1; }
  100% { opacity: 0; transform: translateY(-10px); }
}

#hint {
  position: absolute; left: 50%; bottom: 88px; transform: translateX(-50%);
  font-size: 12px; color: rgba(255, 255, 255, .55); text-shadow: 0 1px 2px #000;
  animation: hintFade .8s ease 28s forwards;
}
#hint b { color: #ffd479; }
@keyframes hintFade { to { opacity: 0; visibility: hidden; } }

/* 物品栏 */
#hotbar {
  position: absolute; left: 50%; bottom: 18px; transform: translateX(-50%);
  display: flex; gap: 4px; padding: 4px;
  background: rgba(0, 0, 0, .35); border-radius: 6px;
  pointer-events: auto;
}
.slot {
  position: relative; width: 52px; height: 52px;
  background: rgba(255, 255, 255, .08);
  border: 2px solid rgba(255, 255, 255, .18);
  border-radius: 4px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
}
.slot.active { border-color: #fff; background: rgba(255, 255, 255, .22); box-shadow: 0 0 10px rgba(255,255,255,.35); }
.slot canvas { width: 40px; height: 40px; image-rendering: pixelated; }
.slot .num {
  position: absolute; right: 2px; bottom: 0; font-size: 10px;
  color: rgba(255, 255, 255, .7); text-shadow: 0 1px 1px #000;
}
.slot .label {
  position: absolute; left: 50%; top: -22px; transform: translateX(-50%);
  font-size: 12px; white-space: nowrap; background: rgba(0,0,0,.75);
  padding: 2px 6px; border-radius: 3px; opacity: 0; transition: opacity .15s;
  pointer-events: none;
}
.slot:hover .label { opacity: 1; }

/* 屏幕覆盖层 */
#water-overlay {
  position: absolute; inset: 0; pointer-events: none;
  background: radial-gradient(circle at 50% 50%, rgba(30,110,190,.22), rgba(10,60,130,.55));
  mix-blend-mode: multiply;
}
#damage-overlay {
  position: absolute; inset: 0; pointer-events: none; opacity: 0;
  background: radial-gradient(circle at 50% 50%, transparent 40%, rgba(180,0,0,.75));
  transition: opacity .35s;
}
#damage-overlay.hit { opacity: 1; transition: opacity .05s; }

/* ---------------- 弹窗面板 ---------------- */
.screen {
  position: absolute; inset: 0; z-index: 10;
  display: flex; align-items: flex-start; justify-content: center;
  background: rgba(6, 10, 14, .72);
  backdrop-filter: blur(3px);
  padding: 20px;
  overflow: auto;
}
.screen.hidden { display: none !important; }

.panel {
  margin: auto;  /* 内容比屏幕高时可以正常滚动，不会被裁掉顶部 */
  width: min(440px, 94vw);
  background: linear-gradient(180deg, #2b3238, #1d2328);
  border: 3px solid #0b0e11;
  box-shadow: inset 0 0 0 3px #4a555e, 0 18px 50px rgba(0, 0, 0, .6);
  padding: 26px 24px;
  border-radius: 4px;
  text-align: center;
}
.panel.wide { width: min(760px, 96vw); }
.panel h1 { font-size: 30px; letter-spacing: 2px; text-shadow: 0 3px 0 #0b0e11; }
.panel h1 .sub { font-size: 18px; color: #9fb4c2; letter-spacing: 0; }
.panel h2 { font-size: 20px; margin-bottom: 14px; letter-spacing: 1px; }
.tagline { font-size: 12px; color: #9fb4c2; margin: 6px 0 20px; }

.row {
  display: flex; align-items: center; gap: 10px;
  margin: 10px 0; font-size: 14px; color: #cfe0ea;
}
.row label { flex: 0 0 150px; text-align: left; }
.row.check label { flex: 1; text-align: left; }
.row input[type=text], .row select {
  flex: 1; padding: 8px 10px; font-size: 14px;
  background: #12171b; color: #e8eef2;
  border: 2px solid #0b0e11; box-shadow: inset 0 0 0 1px #39434b;
  border-radius: 2px; outline: none;
}
.row input[type=range] { flex: 1; accent-color: #6cc04a; }

.buttons { display: flex; flex-direction: column; gap: 10px; margin-top: 20px; }
.buttons button, button {
  padding: 11px 16px; font-size: 15px; cursor: pointer;
  color: #f2f7fa; font-family: inherit; letter-spacing: 1px;
  background: linear-gradient(180deg, #6b7780, #4a545c);
  border: 2px solid #0b0e11;
  box-shadow: inset 0 2px 0 rgba(255, 255, 255, .25), inset 0 -3px 0 rgba(0, 0, 0, .35);
  border-radius: 3px;
  transition: filter .12s;
}
.buttons button:hover, button:hover { filter: brightness(1.22); }
.buttons button:active { transform: translateY(1px); }
.buttons button.primary {
  background: linear-gradient(180deg, #7cc44f, #4b8c2a);
  font-weight: 600;
}

.save-info { margin-top: 14px; font-size: 12px; color: #8fa3af; min-height: 16px; }

.keys { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 18px; text-align: left; font-size: 13px; }
.keys > div { display: flex; align-items: center; gap: 6px; }
.keys span { color: #c3d4de; }
kbd {
  display: inline-block; min-width: 22px; text-align: center;
  padding: 2px 6px; font: 12px/1.4 Consolas, monospace;
  background: #12171b; border: 1px solid #4a555e; border-bottom-width: 2px;
  border-radius: 3px; color: #e8eef2;
}
.tip { font-size: 12px; color: #93a7b4; margin-top: 14px; line-height: 1.6; }

.inv-grid {
  display: grid; grid-template-columns: repeat(8, 1fr); gap: 6px;
  margin: 14px 0; max-height: 46vh; overflow: auto; padding: 4px;
}
.inv-grid .cell {
  aspect-ratio: 1; display: flex; align-items: center; justify-content: center;
  background: rgba(255, 255, 255, .07); border: 2px solid rgba(255, 255, 255, .14);
  border-radius: 4px; cursor: pointer; position: relative;
}
.inv-grid .cell:hover { background: rgba(255, 255, 255, .2); border-color: #fff; }
.inv-grid .cell canvas { width: 70%; height: 70%; image-rendering: pixelated; }
.inv-grid .cell .label {
  position: absolute; left: 50%; bottom: -4px; transform: translate(-50%, 100%);
  font-size: 11px; background: rgba(0, 0, 0, .8); padding: 2px 5px; border-radius: 3px;
  opacity: 0; transition: opacity .15s; white-space: nowrap; z-index: 3;
}
.inv-grid .cell:hover .label { opacity: 1; }

.bar { height: 12px; background: #12171b; border: 2px solid #0b0e11; box-shadow: inset 0 0 0 1px #39434b; border-radius: 6px; overflow: hidden; }
.bar > div { height: 100%; width: 0%; background: linear-gradient(90deg, #7cc44f, #b7e07a); transition: width .2s; }

#error .panel { border-color: #5a1f1f; }

/* 故障面板里的现场信息 */
.diag {
  text-align: left;
  font: 11px/1.6 Consolas, "Courier New", monospace;
  white-space: pre-wrap;
  background: rgba(0, 0, 0, .38);
  border: 1px solid rgba(255, 255, 255, .12);
  border-radius: 4px;
  padding: 10px 12px;
  margin-top: 6px;
  max-height: 34vh;
  overflow: auto;
  color: #b9cbd6;
  user-select: text;
}
#crashTitle { color: #ffb454; }

/* ============================================================
 * 学习功能
 * ============================================================ */

/* HUD 上的可玩时间 */
#study-timer {
  position: absolute; right: 14px; top: 12px;
  font: 15px/1 Consolas, "Courier New", monospace;
  padding: 8px 12px; border-radius: 8px;
  background: rgba(0, 0, 0, .45);
  border: 1px solid rgba(255, 255, 255, .18);
  color: #cfe8ff; text-shadow: 0 1px 3px #000;
}
#study-timer .study-timer-label { font-size: 11px; color: #8fa9bd; font-family: inherit; }
#study-timer.low { color: #ffd479; border-color: #ffd479; }
#study-timer.critical {
  color: #ff9a9a; border-color: #ff6b6b;
  animation: studyPulse 1s ease-in-out infinite;
}
@keyframes studyPulse { 50% { opacity: .45; } }

/* 答题面板 */
.study-panel { text-align: left; }
.study-panel h2 { text-align: center; }
.study-meta { font-size: 12px; color: #93a7b4; margin-bottom: 12px; text-align: center; line-height: 1.6; }

.study-audio {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 10px 12px; margin-bottom: 12px;
  background: rgba(40, 90, 140, .28);
  border: 1px solid rgba(120, 190, 255, .35);
  border-radius: 6px;
}
.study-audio button { padding: 8px 14px; font-size: 14px; }
.study-plays { font-size: 12px; color: #a8c4d8; }

.study-passage {
  font-size: 16px; line-height: 2; color: #e8f1f7;
  background: rgba(255, 255, 255, .06);
  border-left: 3px solid #6cc04a;
  border-radius: 4px;
  padding: 14px 16px; margin-bottom: 16px;
  white-space: pre-wrap; max-height: 34vh; overflow: auto;
}
/* 英语原文用西文排版（不首行缩进），中文翻译单独一块 */
.study-passage-en { font-family: "Segoe UI", Arial, sans-serif; }
.study-passage-zh {
  margin-top: 12px; padding-top: 10px;
  border-top: 1px dashed rgba(255, 255, 255, .22);
  color: #a9c6d8; font-size: 14px; line-height: 1.9;
}

/* 运行日志文本框 */
.journal {
  width: 100%; margin-top: 10px;
  font: 11px/1.6 Consolas, "Courier New", monospace;
  background: #0d1116; color: #b9cbd6;
  border: 2px solid #0b0e11; box-shadow: inset 0 0 0 1px #39434b;
  border-radius: 4px; padding: 10px; outline: none; resize: vertical;
  white-space: pre; user-select: text;
}

.study-questions { display: flex; flex-direction: column; gap: 14px; }
.study-q {
  background: rgba(255, 255, 255, .05);
  border: 1px solid rgba(255, 255, 255, .12);
  border-radius: 6px; padding: 12px 14px;
}
.study-q-title { font-size: 15px; font-weight: 600; margin-bottom: 8px; line-height: 1.6; }
.study-options { display: flex; flex-direction: column; gap: 6px; }
.study-option {
  display: flex; align-items: flex-start; gap: 8px;
  font-size: 14px; line-height: 1.6; cursor: pointer;
  padding: 6px 8px; border-radius: 4px;
}
.study-option:hover { background: rgba(255, 255, 255, .1); }
.study-option input { margin-top: 4px; accent-color: #6cc04a; }

.study-notice { color: #ffb454; font-size: 13px; margin-top: 10px; min-height: 18px; line-height: 1.6; }

.study-score { font-size: 20px; font-weight: 700; text-align: center; margin-bottom: 6px; }
.study-score.full { color: #8ee06a; }
.study-reward {
  text-align: center; font-size: 14px; color: #ffd479;
  background: rgba(120, 90, 0, .28);
  border: 1px solid rgba(255, 212, 121, .4);
  border-radius: 6px; padding: 8px 10px; margin-bottom: 12px; line-height: 1.7;
}
.study-review { display: flex; flex-direction: column; gap: 8px; max-height: 30vh; overflow: auto; }
.study-review-row {
  font-size: 13px; line-height: 1.7; padding: 8px 10px; border-radius: 4px;
  background: rgba(255, 255, 255, .05);
  border-left: 3px solid #777;
}
.study-review-row.ok { border-left-color: #6cc04a; }
.study-review-row.bad { border-left-color: #e05a5a; }
.study-explain { color: #9fb4c2; }

.study-h3 {
  font-size: 14px; color: #cfe0ea; margin: 18px 0 6px;
  border-bottom: 1px solid rgba(255, 255, 255, .14); padding-bottom: 4px;
}
#parent .panel { text-align: left; }
#parent .panel h2 { text-align: center; }
#parent .row > span { color: #93a7b4; font-size: 13px; }
#parent textarea {
  flex: 1; font: 12px/1.5 Consolas, monospace;
  background: #12171b; color: #e8eef2;
  border: 2px solid #0b0e11; box-shadow: inset 0 0 0 1px #39434b;
  border-radius: 2px; padding: 8px; outline: none; resize: vertical;
}
#parent .row label { flex: 0 0 210px; }

/* ============================================================
 * 联机：状态、聊天
 * ============================================================ */
#mp-status {
  position: absolute; right: 14px; top: 12px;
  font: 13px/1 "Microsoft YaHei", system-ui, sans-serif;
  padding: 8px 12px; border-radius: 8px;
  background: rgba(20, 90, 60, .5);
  border: 1px solid rgba(120, 230, 170, .5);
  color: #d6ffe9; text-shadow: 0 1px 3px #000;
}
#mp-status.warn {
  background: rgba(120, 80, 0, .5);
  border-color: #ffb454;
  color: #ffe6c0;
}
/* 可玩时间在联机状态下挪下来一行，避免和联机状态重叠 */
#study-timer { top: 12px; }
#mp-status:not(.hidden) ~ #chatlog { bottom: 96px; }

#chatlog {
  position: absolute; left: 14px; bottom: 96px;
  width: min(420px, 42vw); max-height: 30vh;
  overflow: hidden;
  display: flex; flex-direction: column; justify-content: flex-end; gap: 3px;
  pointer-events: auto;
  font-size: 13px; line-height: 1.5;
  text-shadow: 0 1px 3px #000;
}
.chat-line {
  background: rgba(0, 0, 0, .42);
  border-radius: 4px; padding: 3px 8px;
  color: #eaf3f8;
  transition: opacity .6s;
  word-break: break-word;
}
.chat-line.system { color: #a8c4d8; font-style: italic; background: rgba(0, 0, 0, .28); }
.chat-line.faded { opacity: .35; }
.chat-name { font-weight: 600; }

#chatbar {
  position: absolute; left: 50%; bottom: 92px; transform: translateX(-50%);
  width: min(620px, 78vw);
  pointer-events: auto;
}
#chatbar input {
  width: 100%; padding: 10px 14px; font-size: 15px;
  background: rgba(10, 14, 18, .88); color: #eaf3f8;
  border: 2px solid #4a555e; border-radius: 6px; outline: none;
  box-shadow: 0 6px 20px rgba(0, 0, 0, .5);
}
#chatbar input:focus { border-color: #7cc44f; }
