/* ===== 基础 ===== */
* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

:root {
  --bg: #1d1c1b;
  --panel: #2b2a28;
  --panel-2: #38363380;
  --line-dark: #11111080;
  --line-light: #ffffff22;
  --grass: #5b8a34;
  --grass-dark: #3e6024;
  --dirt: #6b4a2b;
  --gold: #fcdc2c;
  --txt: #e9e9e9;
  --txt-dim: #b8b3a8;
  --accent: #3aa6ff;
  --shadow: 0 6px 0 #00000066;
}

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--txt);
  font-family: -apple-system, "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
}

body {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100dvh;
  /* 仿 Minecraft 深色石纹理 */
  background-image:
    linear-gradient(var(--line-light) 1px, transparent 1px),
    linear-gradient(90deg, var(--line-light) 1px, transparent 1px),
    radial-gradient(circle at 50% 0, #2a2927 0%, var(--bg) 60%);
  background-size: 32px 32px, 32px 32px, 100% 100%;
}

img { image-rendering: pixelated; image-rendering: crisp-edges; }

/* ===== 顶栏 ===== */
.sticky-head { position: sticky; top: 0; z-index: 20; }
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px calc(12px + env(safe-area-inset-top)) 16px;
  padding-top: max(12px, env(safe-area-inset-top));
  background: linear-gradient(var(--grass) 0%, var(--grass) 55%, var(--dirt) 55%, var(--dirt) 100%);
  border-bottom: 4px solid #1a1a1a;
  box-shadow: 0 4px 0 #00000055;
}
.logo { display: flex; align-items: center; gap: 12px; min-width: 0; }
.logo-icon {
  width: 44px; height: 44px;
  filter: drop-shadow(2px 2px 0 #00000088);
  animation: bob 3s ease-in-out infinite;
}
@keyframes bob { 0%,100%{ transform: translateY(0) } 50%{ transform: translateY(-3px) } }
.titles { min-width: 0; }
h1 {
  font-family: "Press Start 2P", monospace;
  font-size: clamp(14px, 3.6vw, 20px);
  color: #fff;
  text-shadow: 2px 2px 0 #2c1d0e, 4px 4px 0 #00000055;
  letter-spacing: .5px;
  white-space: nowrap;
}
.subtitle {
  font-family: "VT323", monospace;
  font-size: 16px;
  color: #f3ead2;
  text-shadow: 1px 1px 0 #2c1d0e;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ===== Minecraft 按钮 ===== */
.mc-btn {
  font-family: "Press Start 2P", monospace;
  font-size: 10px;
  color: #fff;
  text-shadow: 2px 2px 0 #1f1f1f;
  background: #7a7a7a;
  border: 2px solid #000;
  box-shadow: inset 2px 2px 0 #b0b0b0, inset -2px -2px 0 #404040;
  padding: 10px 14px;
  cursor: pointer;
  user-select: none;
  transition: filter .08s, transform .05s;
  -webkit-touch-callout: none;
}
.mc-btn:active { transform: translateY(2px); box-shadow: inset 2px 2px 0 #404040, inset -2px -2px 0 #b0b0b0; }
.mc-btn.ghost { background: #5a5a5a; }
.mc-btn.on { background: var(--accent); box-shadow: inset 2px 2px 0 #8fd0ff, inset -2px -2px 0 #1a5e94; }

.topbar-right { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.voice-sel {
  font-family: -apple-system, system-ui, sans-serif;
  font-size: 13px;
  color: #fff;
  background: #2b2a28;
 border: 2px solid #000;
  box-shadow: inset 2px 2px 0 #4a4843, inset -2px -2px 0 #1f1d1a;
  padding: 8px 8px;
  border-radius: 2px;
  max-width: 130px;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, #fff 50%), linear-gradient(135deg, #fff 50%, transparent 50%);
  background-position: calc(100% - 12px) 14px, calc(100% - 7px) 14px;
  background-size: 5px 5px;
  background-repeat: no-repeat;
}
.voice-sel:focus { outline: 2px solid var(--accent); }

/* ===== Tab 栏 ===== */
.tabs {
  display: flex;
  gap: 8px;
  padding: 12px 14px;
  overflow-x: auto;
  overflow-y: hidden;
  scroll-snap-type: x proximity;
  background: #232220;
  border-bottom: 3px solid #111;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
  scrollbar-color: var(--grass) transparent;
}
.tabs::-webkit-scrollbar { height: 6px; }
.tabs::-webkit-scrollbar-thumb { background: var(--grass); border-radius: 0; }
.tab {
  scroll-snap-align: start;
  flex: 0 0 auto;
  white-space: nowrap;
}
.tab.active { background: var(--grass); box-shadow: inset 2px 2px 0 #9fd070, inset -2px -2px 0 #2c4519; }

/* ===== 内容 / 网格 ===== */
.content { flex: 1; padding: 14px; }
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
  gap: 12px;
  max-width: 1200px;
  margin: 0 auto;
}

/* ===== 物品卡片 ===== */
.card {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 10px 6px 8px;
  background: #34322f;
  border: 2px solid #15140f;
  box-shadow: inset 2px 2px 0 #4a4843, inset -2px -2px 0 #1f1d1a;
  border-radius: 3px;
  cursor: pointer;
  font: inherit;
  color: var(--txt);
  transition: transform .06s, background .12s;
  -webkit-touch-callout: none;
}
.card:hover { background: #3d3b37; }
.card:active, card.pressed { transform: translateY(2px) scale(.98); }

.img-wrap {
  position: relative;
  width: 64px; height: 64px;
  display: grid;
  place-items: center;
  background:
    linear-gradient(45deg, #2a2826 25%, transparent 25%, transparent 75%, #2a2826 75%),
    linear-gradient(45deg, #2a2826 25%, #211f1d 25%, #211f1d 75%, #2a2826 75%);
  background-size: 12px 12px;
  background-position: 0 0, 6px 6px;
  border: 1px solid #15140f;
  overflow: hidden;
}
.img-wrap.sprite {
  background-color: #211f1d;
  background-repeat: no-repeat;
}
.img-wrap img {
  width: 52px; height: 52px;
  object-fit: contain;
  filter: drop-shadow(1px 1px 0 #00000088);
}

.en {
  font-size: 12px;
  line-height: 1.2;
  text-align: center;
  color: var(--txt-dim);
  min-height: 2.4em;
  display: flex;
  align-items: center;
  text-shadow: 1px 1px 0 #000;
  word-break: break-word;
}

/* 中文名浮层 */
.zh {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(10, 10, 10, .86);
  color: var(--gold);
  font-size: 18px;
  font-weight: 700;
  text-align: center;
  padding: 4px;
  opacity: 0;
  transform: scale(.7);
  transition: opacity .15s ease, transform .15s ease;
  pointer-events: none;
  text-shadow: 2px 2px 0 #000, 0 0 8px #fcdc2c55;
  border: 2px solid var(--gold);
  letter-spacing: 1px;
}
.card.active .zh { opacity: 1; transform: scale(1); }
.card.active { background: #4a463e; box-shadow: inset 2px 2px 0 #6a655a, inset -2px -2px 0 #2a2722, 0 0 0 2px var(--gold); }

/* ===== Toast ===== */
.toast {
  position: fixed;
  left: 50%;
  bottom: max(20px, env(safe-area-inset-bottom));
  transform: translateX(-50%) translateY(20px);
  background: #111c;
  color: #fff;
  border: 2px solid var(--gold);
  padding: 10px 16px;
  font-size: 14px;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s, transform .2s;
  z-index: 50;
  font-family: "VT323", monospace;
  font-size: 18px;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ===== 响应式 / iPad ===== */
@media (min-width: 640px) {
  .grid { grid-template-columns: repeat(auto-fill, minmax(108px, 1fr)); gap: 14px; }
  .en { font-size: 13px; }
  .zh { font-size: 20px; }
}
@media (min-width: 1024px) {
  .grid { grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 16px; }
  .content { padding: 20px; }
}

/* 横屏低矮：压缩顶栏 */
@media (max-height: 500px) and (orientation: landscape) {
  .topbar { padding-top: max(6px, env(safe-area-inset-top)); padding-bottom: 6px; }
  .tabs { padding: 8px 14px; }
  .logo-icon { width: 34px; height: 34px; }
  .subtitle { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .logo-icon { animation: none; }
}
