/* ============ 我的世界 · 背单词行动 ============ */
:root {
  --mc-gray: #6f6f6f;
  --mc-dark: #3a3a3a;
  --btn-face: #8b8b8b;
  --btn-light: #a8a8a8;
  --btn-dark: #565656;
  --grass: #7cbd45;
  --grass-dark: #5a9a2e;
  --dirt: #8a5a34;
  --stone: #9a9a9a;
  --gold: #fcdb05;
  --red: #e0393e;
  --blue: #4a90d9;
  --font-en: 'Press Start 2P', monospace;
  --font-cn: 'Microsoft YaHei', 'PingFang SC', sans-serif;
}

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

body {
  background: #1b1b1b;
  color: #eee;
  font-family: var(--font-cn);
  min-height: 100vh;
  overflow-x: hidden;
  image-rendering: pixelated;
  -webkit-tap-highlight-color: transparent;
}

.hidden { display: none !important; }

.screen {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 24px 16px 48px;
}
.mc-btn, .choice-btn, .item-btn {
  touch-action: manipulation;
  -webkit-user-select: none;
  user-select: none;
}
.home-install-tip {
  font-size: 12px;
  color: #9f9;
  background: rgba(0,0,0,.55);
  border: 2px solid #000;
  padding: 6px 12px;
  text-align: center;
}

h1, h2, h3 { font-weight: 700; }

/* ---------- MC 风格按钮 ---------- */
.mc-btn {
  display: inline-block;
  background: var(--btn-face);
  color: #fff;
  border: 2px solid #000;
  box-shadow: inset 2px 2px 0 var(--btn-light), inset -2px -2px 0 var(--btn-dark), 0 3px 0 #000;
  padding: 12px 24px;
  font-size: 16px;
  font-family: var(--font-cn);
  cursor: pointer;
  text-shadow: 1px 1px 0 #3f3f3f;
  user-select: none;
  transition: transform .05s;
}
.mc-btn:hover { background: #9a9aa8; }
.mc-btn:active { transform: translateY(2px); box-shadow: inset 2px 2px 0 var(--btn-dark), inset -2px -2px 0 var(--btn-light), 0 1px 0 #000; }
.mc-btn:disabled { opacity: .45; cursor: not-allowed; transform: none; background: #6a6a6a; }
.mc-btn:disabled:hover { background: #6a6a6a; }
.mc-btn.big { font-size: 20px; padding: 16px 40px; }
.mc-btn.small { padding: 6px 12px; font-size: 13px; }
.mc-btn.back { align-self: flex-start; }
.mc-btn.danger { background: #a04040; }
.mc-btn.danger:hover { background: #b05050; }
.mc-btn.correct-flash { background: var(--grass-dark); }
.mc-btn.wrong-flash { background: #a04040; }

.mc-menu {
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-width: 340px;
}
.mc-menu.row { flex-direction: row; gap: 16px; }

/* ---------- 主菜单 ---------- */
#screen-home { justify-content: center; }
.home-bg {
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    linear-gradient(180deg, #78a7ff 0%, #9fc4ff 45%, #5a9a2e 45.5%, #3d6b1e 60%, #6b4a2b 60.5%, #4a331d 100%);
}
.home-bg::before {
  /* 像素云 */
  content: '';
  position: absolute;
  top: 40px; left: 8%;
  width: 220px; height: 44px;
  background: #fff;
  box-shadow: 24px -22px 0 -6px #fff, 480px 60px 0 0 #fff, 760px 30px 0 6px #fff, 300px -40px 0 -10px #fff, 900px 90px 0 -4px #fff;
  opacity: .9;
}
.home-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 34px;
  z-index: 1;
}

.logo-wrap { text-align: center; }
.logo-block {
  width: 72px; height: 72px;
  margin: 0 auto 18px;
  position: relative;
  background: var(--dirt);
  border: 3px solid #000;
  animation: bob 2.4s ease-in-out infinite;
}
.logo-face.top {
  position: absolute; inset: 0 0 60% 0;
  background:
    repeating-linear-gradient(90deg, var(--grass) 0 12px, var(--grass-dark) 12px 24px);
  border-bottom: 3px solid #000;
}
.logo-face.front {
  position: absolute; inset: 40% 0 0 0;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-en);
  color: #2e1d10;
  font-size: 18px;
  text-shadow: 1px 1px 0 #a5713f;
}
@keyframes bob { 0%,100% { transform: translateY(0);} 50% { transform: translateY(-8px);} }

.game-title {
  font-family: var(--font-en), var(--font-cn);
  font-size: 30px;
  color: #fff;
  letter-spacing: 2px;
  text-shadow: 3px 3px 0 #2c2c2c, -2px -2px 0 #2c2c2c, 2px -2px 0 #2c2c2c, -2px 2px 0 #2c2c2c;
}
.title-sub {
  display: block;
  font-family: var(--font-cn);
  font-size: 18px;
  margin-top: 14px;
  color: var(--gold);
  text-shadow: 2px 2px 0 #2c2c2c;
}
.title-tagline {
  margin-top: 12px;
  font-size: 13px;
  color: #ffe9b0;
  text-shadow: 1px 1px 0 #333;
}

.home-tip {
  margin-top: 6px;
  font-size: 13px;
  color: #cfcfcf;
  background: rgba(0,0,0,.55);
  border: 2px solid #000;
  padding: 8px 16px;
}

/* ---------- 面板头部 ---------- */
.panel-header {
  width: 100%;
  max-width: 860px;
  display: flex;
  align-items: center;
  gap: 20px;
  margin-bottom: 26px;
}
.panel-header h2 { font-size: 24px; text-shadow: 2px 2px 0 #222; }

/* ---------- 词书 ---------- */
.book-list {
  display: flex;
  flex-direction: column;
  gap: 14px;
  width: 100%;
  max-width: 680px;
}
.book-item {
  display: flex;
  align-items: center;
  gap: 18px;
  background: rgba(0,0,0,.5);
  border: 3px solid #000;
  box-shadow: inset 2px 2px 0 #555, inset -2px -2px 0 #222;
  padding: 16px 20px;
  cursor: pointer;
}
.book-item:hover { background: rgba(60,60,80,.6); }
.book-item.active { outline: 3px solid var(--gold); }
.book-icon {
  width: 48px; height: 48px;
  border: 3px solid #000;
  flex: none;
  background: repeating-linear-gradient(90deg, var(--grass) 0 8px, var(--grass-dark) 8px 16px);
}
.book-icon.blue { background: repeating-linear-gradient(90deg, #58c0f0 0 8px, #3a95c8 8px 16px); }
.book-icon.custom { background: repeating-linear-gradient(90deg, #d8b58a 0 8px, #b28a5a 8px 16px); }
.book-info h3 { font-size: 18px; margin-bottom: 6px; }
.book-info p { font-size: 13px; color: #bbb; }

.book-detail {
  margin-top: 18px;
  width: 100%;
  max-width: 680px;
  background: rgba(0,0,0,.5);
  border: 3px solid #000;
  padding: 18px 22px;
  font-size: 14px;
  line-height: 1.9;
  color: #ccc;
}

/* ---------- 游戏 HUD ---------- */
#screen-game { padding: 12px 16px; }
.hud {
  width: 100%;
  max-width: 900px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  background: rgba(0,0,0,.5);
  border: 3px solid #000;
  padding: 10px 16px;
}
.hud-left, .hud-right { display: flex; flex-direction: column; gap: 6px; align-items: flex-start; }
.hud-right { align-items: flex-end; }
.hearts { font-size: 18px; letter-spacing: 4px; }
.heart-lost { filter: grayscale(1) brightness(.5); }
.hud-streak { font-size: 14px; color: var(--gold); }
.hud-drop { font-size: 12px; color: #7fd4e0; }
.hud-center { display: flex; flex-direction: column; align-items: center; gap: 4px; flex: 1; }
.xp-bar-wrap {
  width: 200px; height: 14px;
  background: #222;
  border: 2px solid #000;
}
.xp-bar {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #7cf642, #3fc41c);
  transition: width .3s;
}
.xp-text { font-size: 12px; color: #8f8; font-family: var(--font-en); }
.hud-progress { font-family: var(--font-en); font-size: 14px; color: #ccc; }

/* 挖矿条 */
.mine-strip {
  display: flex;
  gap: 8px;
  margin: 22px 0;
  flex-wrap: wrap;
  justify-content: center;
}
.mine-block {
  width: 34px; height: 34px;
  border: 2px solid #000;
  position: relative;
  background: var(--dirt);
  transition: filter .2s;
}
.mine-block.mat-stone { background: var(--stone); }
.mine-block.mat-iron { background: #d8af93; }
.mine-block.mat-gold { background: var(--gold); }
.mine-block.mat-diamond { background: #7ce0e3; }
.mine-block.mat-obsidian { background: #2b2340; }
.mine-block.broken {
  background: #181818 !important;
  filter: brightness(.7);
}
.mine-block.current { outline: 3px solid var(--gold); animation: pulse 1s infinite; }
@keyframes pulse { 50% { outline-color: #fff7c0; } }
.mine-block.broken::after {
  content: '';
  position: absolute; inset: 0;
  background:
    linear-gradient(45deg, transparent 40%, #000 40% 45%, transparent 45% 60%, #000 60% 65%, transparent 65%),
    linear-gradient(-45deg, transparent 30%, #000 30% 34%, transparent 34% 55%, #000 55% 60%, transparent 60%);
  opacity: .8;
}

/* 题目区 */
.question-area {
  width: 100%;
  max-width: 760px;
  background: rgba(0,0,0,.55);
  border: 3px solid #000;
  box-shadow: inset 2px 2px 0 #444, inset -2px -2px 0 #1a1a1a;
  padding: 28px 30px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
}
.q-label { font-size: 14px; color: #9f9; letter-spacing: 2px; }
.q-word {
  font-family: var(--font-en), var(--font-cn);
  font-size: 34px;
  color: #fff;
  text-align: center;
  text-shadow: 2px 2px 0 #333;
  line-height: 1.4;
  word-break: break-all;
}
.q-word.cn { font-family: var(--font-cn); font-size: 28px; }

.choices {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  width: 100%;
}
.choice-btn {
  text-align: left;
  padding: 14px 18px;
  font-size: 16px;
}
.choice-btn.math-choice {
  text-align: center;
  font-family: var(--font-en), var(--font-cn);
  font-size: 22px;
  padding: 18px 12px;
}

.spell-area { display: flex; gap: 12px; width: 100%; }
.spell-input {
  flex: 1;
  background: #111;
  color: #fff;
  border: 2px solid #000;
  box-shadow: inset 2px 2px 0 #333;
  padding: 12px 16px;
  font-size: 18px;
  font-family: var(--font-en), var(--font-cn);
  outline: none;
}
.spell-input:focus { border-color: var(--gold); }

.q-feedback {
  min-height: 26px;
  font-size: 15px;
  text-align: center;
}
.q-feedback.ok { color: #7cf642; }
.q-feedback.bad { color: #ff6b6b; }

/* 局内道具栏 */
.item-bar {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: center;
}
.item-btn { font-size: 13px; padding: 8px 14px; }
.q-hint {
  font-family: var(--font-en), var(--font-cn);
  color: var(--gold);
  font-size: 16px;
  letter-spacing: 2px;
  min-height: 20px;
}

/* 村民商店 */
.shop-resources {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 18px;
  width: 100%;
  max-width: 680px;
}
.shop-resources .inv-slot { width: auto; padding: 0 12px; font-size: 14px; white-space: nowrap; }
.shop-list {
  display: flex;
  flex-direction: column;
  gap: 14px;
  width: 100%;
  max-width: 680px;
}
.shop-item {
  display: flex;
  align-items: center;
  gap: 16px;
  background: rgba(0,0,0,.5);
  border: 3px solid #000;
  box-shadow: inset 2px 2px 0 #444, inset -2px -2px 0 #1a1a1a;
  padding: 14px 18px;
}
.shop-icon { font-size: 30px; width: 52px; text-align: center; flex: none; }
.shop-info { flex: 1; }
.shop-info h3 { font-size: 16px; margin-bottom: 4px; }
.shop-info p { font-size: 13px; color: #bbb; line-height: 1.5; }
.shop-stock { font-size: 12px; color: #8f8; font-weight: 400; }

/* ---- 村庄 ---- */
.v-level { font-size: 14px; color: var(--gold); margin-left: 10px; }
.village-resources {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 16px;
  width: 100%;
  max-width: 860px;
}
.village-resources .inv-slot { width: auto; padding: 0 12px; font-size: 14px; white-space: nowrap; }
.village-map-wrap {
  position: relative;
  width: 100%;
  max-width: 860px;
  border: 3px solid #000;
  margin-bottom: 14px;
  line-height: 0;
}
#village-canvas {
  display: block;
  width: 100%;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}
.v-map-tip {
  position: absolute;
  background: rgba(0,0,0,.88);
  border: 2px solid #000;
  color: #fff;
  padding: 4px 10px;
  font-size: 13px;
  pointer-events: none;
  z-index: 5;
  white-space: nowrap;
  line-height: 1.4;
}
.shop-item.flash { outline: 3px solid var(--gold); }
.village-tip {
  width: 100%;
  max-width: 860px;
  font-size: 13px;
  color: #bbb;
  margin-bottom: 14px;
  line-height: 1.6;
}
.village-list {
  display: flex;
  flex-direction: column;
  gap: 14px;
  width: 100%;
  max-width: 860px;
}

/* 背包 */
.inventory {
  margin-top: 22px;
  display: flex;
  gap: 10px;
  min-height: 44px;
  align-items: center;
  flex-wrap: wrap;
  justify-content: center;
}
.inv-slot {
  width: 40px; height: 40px;
  background: #8b8b8b;
  border: 2px solid #000;
  box-shadow: inset 2px 2px 0 #aaa, inset -2px -2px 0 #555;
  display: flex; align-items: center; justify-content: center;
  font-size: 20px;
}
.inv-slot .count {
  position: absolute;
}

/* ---------- 结算 ---------- */
#screen-result { justify-content: center; }
.result-card {
  background: rgba(0,0,0,.65);
  border: 3px solid #000;
  box-shadow: 0 0 0 3px #555 inset;
  padding: 34px 40px;
  text-align: center;
  max-width: 560px;
  width: 100%;
}
.result-card h2 { margin-bottom: 22px; text-shadow: 2px 2px 0 #222; }
.result-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px 24px;
  font-size: 15px;
  margin-bottom: 20px;
  text-align: left;
}
.result-grid b { color: var(--gold); }
.result-items { margin-bottom: 24px; font-size: 14px; color: #ccc; }

/* ---------- 战绩 ---------- */
.stats-grid {
  width: 100%;
  max-width: 760px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 14px;
  margin-bottom: 24px;
}
.stat-cell {
  background: rgba(0,0,0,.5);
  border: 3px solid #000;
  padding: 18px;
  text-align: center;
}
.stat-cell .num { font-family: var(--font-en); font-size: 22px; color: var(--gold); margin-top: 8px; }
.stat-cell .lab { font-size: 13px; color: #aaa; }
.stats-extra {
  width: 100%;
  max-width: 760px;
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
}
.stats-box {
  flex: 1;
  min-width: 280px;
  background: rgba(0,0,0,.5);
  border: 3px solid #000;
  padding: 18px;
}
.stats-box h3 { margin-bottom: 12px; font-size: 16px; }
.stats-items { display: flex; gap: 10px; flex-wrap: wrap; }
.stats-items .inv-slot { width: auto; padding: 0 12px; font-size: 14px; white-space: nowrap; }

/* ---------- 导入 ---------- */
.import-wrap, .settings-wrap {
  width: 100%;
  max-width: 680px;
  background: rgba(0,0,0,.5);
  border: 3px solid #000;
  padding: 24px;
}
.import-tip { font-size: 14px; color: #bbb; margin-bottom: 8px; }
.import-tip code { color: var(--gold); background: #222; padding: 1px 6px; }
.import-text {
  width: 100%;
  background: #111;
  color: #fff;
  border: 2px solid #000;
  padding: 12px;
  font-size: 14px;
  font-family: var(--font-en), var(--font-cn);
  resize: vertical;
  margin: 10px 0 16px;
}
.import-actions { display: flex; align-items: center; gap: 16px; }
.import-msg { font-size: 14px; color: #7cf642; }
.import-msg.err { color: #ff6b6b; }

/* ---------- 设置 ---------- */
.setting-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 0;
  border-bottom: 1px solid #333;
  font-size: 15px;
}
.setting-row select {
  background: #222; color: #fff; border: 2px solid #000; padding: 6px 10px; font-size: 14px;
}
.setting-row input[type=checkbox] { width: 20px; height: 20px; }

/* ---------- 响应式 ---------- */
@media (max-width: 640px) {
  .choices { grid-template-columns: 1fr; }
  .q-word { font-size: 26px; }
  .mc-menu { min-width: 260px; }
  .hud { flex-wrap: wrap; }
}

/* ---------- 移动端适配 ---------- */
@media (min-width: 769px) {
  .home-install-tip { display: none; }
}
@media (max-width: 768px) {
  .screen { padding: 14px 10px 40px; }
  .home-content { gap: 22px; width: 100%; }
  .logo-block { width: 54px; height: 54px; }
  .logo-face.front { inset: 40% 0 0 0; font-size: 13px; }
  .game-title { font-size: 20px; }
  .title-sub { font-size: 14px; margin-top: 8px; }
  .title-tagline { font-size: 11px; }
  .mc-menu { min-width: 0; width: 100%; max-width: 420px; }
  .mc-menu.row { flex-direction: column; gap: 10px; }
  .mc-btn { padding: 12px 14px; font-size: 15px; }
  .mc-btn.big { font-size: 17px; padding: 14px 18px; }
  .hud { flex-wrap: wrap; gap: 8px; padding: 8px 10px; }
  .hud-center { order: 3; width: 100%; flex: none; }
  .xp-bar-wrap { width: 100%; }
  .hud-right { flex-direction: row; align-items: center; gap: 10px; }
  .question-area { padding: 16px 14px; gap: 14px; }
  .q-label { font-size: 12px; }
  .q-word { font-size: 22px; }
  .q-word.cn { font-size: 19px; }
  .mine-strip { gap: 6px; margin: 14px 0; }
  .mine-block { width: 24px; height: 24px; }
  .choices { gap: 8px; }
  .choice-btn { font-size: 14px; padding: 13px 14px; }
  .spell-area { flex-wrap: wrap; gap: 8px; }
  .spell-input { min-width: 0; font-size: 16px; padding: 12px; }
  .q-hint { font-size: 14px; }
  .item-bar { gap: 6px; width: 100%; }
  .item-btn { flex: 1; min-width: 0; font-size: 12px; padding: 10px 4px; }
  .inventory { min-height: 36px; }
  .inv-slot { width: 34px; height: 34px; font-size: 16px; }
  .result-card { padding: 22px 16px; }
  .result-card h2 { font-size: 18px; }
  .result-grid { font-size: 13px; gap: 8px 14px; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .stat-cell { padding: 12px; }
  .stat-cell .num { font-size: 16px; }
  .panel-header h2 { font-size: 18px; }
  .book-item { padding: 12px; }
  .book-info h3 { font-size: 15px; }
  .shop-item { flex-wrap: wrap; gap: 10px; }
  .shop-item button { width: 100%; }
  .setting-row { font-size: 14px; padding: 12px 0; }
  .import-text { font-size: 13px; }
  .v-map-tip { font-size: 12px; }
}
@media (max-width: 480px) {
  .q-word { font-size: 19px; }
  .hud-streak { font-size: 12px; }
  .mine-strip { gap: 5px; }
  .mine-block { width: 20px; height: 20px; }
  .hearts { font-size: 15px; letter-spacing: 2px; }
}
