:root {
  --bg: #070b12;
  --panel: rgba(12, 19, 30, 0.9);
  --ink: #edf4f8;
  --muted: #9db0c2;
  --accent: #a3e635;
  --accent-2: #5eead4;
  --line: rgba(255, 255, 255, 0.1);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
}

body {
  font-family: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", system-ui, -apple-system, sans-serif;
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  user-select: none;
  -webkit-user-select: none;
}

canvas#game {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  outline: none;
  touch-action: none;
}

.vignette {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 2;
  background:
    radial-gradient(120% 95% at 50% 45%, transparent 52%, rgba(2, 6, 12, 0.34) 100%),
    linear-gradient(to bottom, rgba(4, 8, 14, 0.18), transparent 18%, transparent 82%, rgba(4, 8, 14, 0.22));
}

#underwater {
  position: fixed;
  inset: 0;
  z-index: 3;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.35s ease;
  background: radial-gradient(120% 100% at 50% 50%, rgba(28, 100, 140, 0.26), rgba(5, 35, 58, 0.5));
  box-shadow: inset 0 0 160px rgba(0, 20, 40, 0.55);
}
#underwater.on { opacity: 1; }

/* ---------------- crosshair ---------------- */
#crosshair {
  position: fixed;
  left: 50%;
  top: 50%;
  width: 22px;
  height: 22px;
  margin: -11px 0 0 -11px;
  z-index: 6;
  pointer-events: none;
  display: none;
  filter: drop-shadow(0 0 2px rgba(0, 0, 0, 0.85));
}
#crosshair span {
  position: absolute;
  background: rgba(255, 255, 255, 0.92);
  border-radius: 1px;
}
#crosshair span:nth-child(1) { left: 10px; top: 2px; width: 2px; height: 18px; }
#crosshair span:nth-child(2) { top: 10px; left: 2px; height: 2px; width: 18px; }
.mode-playing #crosshair { display: block; }

/* ---------------- hud ---------------- */
#debug {
  position: fixed;
  top: 14px;
  right: 16px;
  z-index: 7;
  padding: 9px 12px;
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: 9px;
  background: rgba(6, 11, 18, 0.42);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  font-family: "Consolas", "SFMono-Regular", monospace;
  font-size: 10.5px;
  line-height: 1.75;
  letter-spacing: 0.02em;
  color: rgba(225, 238, 248, 0.78);
  text-align: right;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.6);
  pointer-events: none;
}
#dbgFps { color: rgba(163, 230, 53, 0.9); }
#dbgInfo { color: rgba(160, 180, 200, 0.66); }

#hud, #hotbarWrap { transition: opacity 0.3s ease; }
.mode-menu #hud, .mode-menu #hotbarWrap,
.mode-loading #hud, .mode-loading #hotbarWrap { opacity: 0; pointer-events: none; }

/* ---------------- hotbar ---------------- */
#hotbarWrap {
  position: fixed;
  left: 50%;
  bottom: 20px;
  transform: translateX(-50%);
  z-index: 7;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 7px;
}

#hotbar {
  display: flex;
  gap: 6px;
  padding: 7px;
  border-radius: 13px;
  border: 1px solid rgba(255, 255, 255, 0.09);
  background: rgba(5, 10, 17, 0.56);
  box-shadow: 0 14px 40px rgba(0, 0, 0, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.06);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.slot {
  position: relative;
  width: 52px;
  height: 52px;
  border-radius: 7px;
  border: 2px solid rgba(255, 255, 255, 0.13);
  background: rgba(255, 255, 255, 0.055);
  display: grid;
  place-items: center;
  transition: transform 0.13s ease, border-color 0.13s ease, background 0.13s ease, box-shadow 0.13s ease;
}
.slot img {
  width: 36px;
  height: 36px;
  image-rendering: pixelated;
  filter: drop-shadow(0 2px 2px rgba(0, 0, 0, 0.45));
  pointer-events: none;
}
.slot .num {
  position: absolute;
  top: 1px;
  left: 5px;
  font-family: "Consolas", monospace;
  font-size: 9px;
  color: rgba(255, 255, 255, 0.45);
}
.slot.active {
  border-color: var(--accent);
  background: rgba(163, 230, 53, 0.13);
  transform: translateY(-5px);
  box-shadow: 0 7px 20px rgba(140, 200, 60, 0.28), inset 0 0 12px rgba(163, 230, 53, 0.1);
}
.slot.active .num { color: rgba(200, 255, 130, 0.9); }

#blockName {
  height: 18px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: rgba(255, 255, 255, 0.92);
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.8);
  opacity: 0;
  transform: translateY(5px);
  transition: opacity 0.2s ease, transform 0.2s ease;
  pointer-events: none;
}
#blockName.show { opacity: 1; transform: translateY(0); }

#hint {
  position: static;
  margin-top: 1px;
  white-space: nowrap;
  font-size: 10.5px;
  color: rgba(215, 230, 242, 0.45);
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.8);
  opacity: 1;
  transition: opacity 0.8s ease;
  pointer-events: none;
}
#hint kbd {
  font-family: inherit;
  font-size: 9.5px;
  padding: 1px 4px;
  border-radius: 3px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: rgba(255, 255, 255, 0.07);
  color: rgba(235, 245, 252, 0.65);
}
#hint.faded { opacity: 0; }

/* ---------------- overlays ---------------- */
.overlay {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background:
    radial-gradient(90% 90% at 50% 35%, rgba(25, 40, 58, 0.38), rgba(3, 6, 11, 0.82)),
    rgba(4, 8, 14, 0.25);
  backdrop-filter: blur(7px) saturate(0.9);
  -webkit-backdrop-filter: blur(7px) saturate(0.9);
}
.mode-menu #menu,
.mode-paused #menu,
.mode-inventory #inventory,
.mode-loading #loading { display: flex; }

.card {
  position: relative;
  width: min(600px, calc(100vw - 32px));
  max-height: calc(100vh - 32px);
  overflow: auto;
  padding: 36px 40px 28px;
  border-radius: 20px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background:
    repeating-linear-gradient(115deg, rgba(255, 255, 255, 0.014) 0 2px, transparent 2px 9px),
    linear-gradient(180deg, rgba(19, 29, 43, 0.95), rgba(8, 13, 21, 0.96));
  box-shadow:
    0 40px 100px rgba(0, 0, 0, 0.6),
    inset 0 1px 0 rgba(255, 255, 255, 0.07);
  animation: cardIn 0.35s cubic-bezier(0.2, 0.9, 0.2, 1);
}
@keyframes cardIn {
  from { opacity: 0; transform: translateY(14px) scale(0.985); }
  to { opacity: 1; transform: none; }
}

.eyebrow {
  font-family: "Consolas", monospace;
  font-size: 10px;
  letter-spacing: 0.24em;
  color: var(--accent);
  text-transform: uppercase;
  opacity: 0.9;
}

h1 {
  margin: 10px 0 10px;
  font-size: clamp(40px, 7vw, 62px);
  line-height: 1.02;
  font-weight: 900;
  letter-spacing: -0.03em;
  background: linear-gradient(112deg, #f4ffe2 5%, #c4f56e 38%, #a3e635 57%, #5eead4 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 8px 24px rgba(120, 200, 80, 0.18));
}

h2 {
  margin: 6px 0 0;
  font-size: 26px;
  letter-spacing: -0.02em;
}

.sub {
  margin: 0;
  max-width: 46ch;
  font-size: 13.5px;
  line-height: 1.8;
  color: var(--muted);
}

.controls {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 7px 22px;
  margin: 26px 0 24px;
  padding: 18px 0;
  border-top: 1px solid rgba(255, 255, 255, 0.07);
  border-bottom: 1px solid rgba(255, 255, 255, 0.07);
}
.controls > div {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  font-size: 11.5px;
  color: rgba(210, 226, 238, 0.72);
}
kbd {
  display: inline-block;
  flex: 0 0 auto;
  min-width: 42px;
  padding: 3px 7px;
  border-radius: 5px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-bottom-color: rgba(255, 255, 255, 0.08);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.09), rgba(255, 255, 255, 0.03));
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.35);
  font-family: "Consolas", "SFMono-Regular", monospace;
  font-size: 10px;
  color: rgba(236, 246, 252, 0.9);
  text-align: center;
  white-space: nowrap;
}

.actions { display: flex; gap: 10px; }
button { font-family: inherit; }

.world-confirm {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-top: 10px;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid rgba(224, 122, 104, 0.34);
  background: rgba(224, 106, 90, 0.11);
}
.world-confirm[hidden] { display: none; }
.world-confirm span {
  font-size: 12px;
  line-height: 1.5;
  color: rgba(255, 216, 209, 0.92);
}
.world-confirm-actions { display: flex; flex: 0 0 auto; gap: 8px; }
button.danger {
  height: 34px;
  padding: 0 16px;
  border: 0;
  border-radius: 8px;
  background: linear-gradient(180deg, #ec7c69, #d85948);
  color: #2a0d09;
  font-size: 12px;
  font-weight: 800;
  cursor: pointer;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.35);
}
button.danger:hover { filter: brightness(1.06); }
button.ghost.small { height: 34px; padding: 0 14px; font-size: 12px; }
button.primary {
  flex: 1;
  height: 48px;
  border: 0;
  border-radius: 10px;
  background: linear-gradient(180deg, #c3f56d, #8ecb31 55%, #79b524);
  color: #13210a;
  font-size: 14px;
  font-weight: 800;
  letter-spacing: 0.03em;
  cursor: pointer;
  box-shadow:
    0 10px 30px rgba(143, 203, 49, 0.28),
    inset 0 1px 0 rgba(255, 255, 255, 0.55),
    inset 0 -2px 0 rgba(0, 0, 0, 0.14);
  transition: transform 0.14s ease, filter 0.14s ease, box-shadow 0.14s ease;
}
button.primary:hover {
  transform: translateY(-1px);
  filter: brightness(1.04);
  box-shadow: 0 14px 36px rgba(143, 203, 49, 0.36), inset 0 1px 0 rgba(255, 255, 255, 0.6);
}
button.primary:active { transform: translateY(1px) scale(0.995); }

button.ghost {
  height: 48px;
  padding: 0 20px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  background: rgba(255, 255, 255, 0.035);
  color: rgba(226, 238, 248, 0.82);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.14s ease, border-color 0.14s ease, color 0.14s ease;
}
button.ghost:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.26);
  color: #fff;
}

.meta {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-top: 18px;
  font-family: "Consolas", monospace;
  font-size: 10px;
  letter-spacing: 0.04em;
  color: rgba(255, 255, 255, 0.34);
}

/* ---------------- inventory ---------------- */
.inv-card { width: min(760px, calc(100vw - 32px)); }
.inv-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 22px;
}
.inv-tip {
  font-size: 10.5px;
  color: rgba(255, 255, 255, 0.38);
  padding-bottom: 4px;
  white-space: nowrap;
}
.inv-tip kbd { min-width: 0; padding: 2px 5px; font-size: 9px; }

.inv-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 9px;
}
.inv-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 12px 6px 9px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.032);
  color: rgba(226, 238, 248, 0.72);
  cursor: pointer;
  transition: transform 0.12s ease, border-color 0.12s ease, background 0.12s ease;
}
.inv-item img {
  width: 42px;
  height: 42px;
  image-rendering: pixelated;
  filter: drop-shadow(0 3px 4px rgba(0, 0, 0, 0.45));
  pointer-events: none;
}
.inv-item span {
  font-size: 10.5px;
  white-space: nowrap;
  pointer-events: none;
}
.inv-item:hover {
  transform: translateY(-2px);
  border-color: rgba(163, 230, 53, 0.5);
  background: rgba(163, 230, 53, 0.08);
  color: #f4ffe4;
}
.inv-item.current-slot { border-color: rgba(163, 230, 53, 0.35); background: rgba(163, 230, 53, 0.05); }

/* ---------------- loading ---------------- */
.mode-loading { cursor: progress; }
.load-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  padding: 30px 40px;
  text-align: center;
}
.logo-mark {
  position: relative;
  width: 72px;
  height: 66px;
  margin-bottom: 8px;
}
.logo-mark i {
  position: absolute;
  width: 30px;
  height: 30px;
  border-radius: 4px;
  background: linear-gradient(145deg, #c9f97a, #7fbf2b);
  box-shadow: inset 0 2px 0 rgba(255, 255, 255, 0.4), 0 6px 14px rgba(0, 0, 0, 0.35);
  animation: floatBlock 1.8s ease-in-out infinite alternate;
}
.logo-mark i:nth-child(1) { left: 4px; top: 24px; animation-delay: -0.3s; }
.logo-mark i:nth-child(2) { left: 34px; top: 8px; background: linear-gradient(145deg, #e9ffc0, #a8e14a); animation-delay: -0.9s; }
.logo-mark i:nth-child(3) {
  left: 34px;
  top: 40px;
  background: linear-gradient(145deg, #86c93a, #5c9420);
  animation-delay: -1.4s;
}
@keyframes floatBlock {
  from { transform: translateY(0) rotate(0deg); }
  to { transform: translateY(-5px) rotate(3deg); }
}
.load-title {
  font-size: 17px;
  font-weight: 800;
  letter-spacing: 0.03em;
}
.bar {
  width: min(280px, 70vw);
  height: 6px;
  margin-top: 2px;
  border-radius: 99px;
  background: rgba(255, 255, 255, 0.08);
  overflow: hidden;
}
.bar span {
  display: block;
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #86c93a, #c9f97a);
  box-shadow: 0 0 12px rgba(163, 230, 53, 0.5);
  transition: width 0.18s ease;
}
.load-text {
  font-family: "Consolas", monospace;
  font-size: 10px;
  letter-spacing: 0.08em;
  color: rgba(200, 218, 232, 0.46);
  min-height: 14px;
}

/* ---------------- responsive ---------------- */
@media (max-width: 640px) {
  .card { padding: 26px 22px 20px; border-radius: 16px; }
  .controls { grid-template-columns: 1fr; gap: 6px; margin: 20px 0; padding: 14px 0; }
  .meta { flex-direction: column; gap: 4px; }
  .inv-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .inv-head { flex-direction: column; align-items: flex-start; gap: 6px; }
  .slot { width: 42px; height: 42px; }
  .slot img { width: 29px; height: 29px; }
  #hotbar { gap: 4px; padding: 6px; }
  #hint { display: none; }
  .actions { flex-direction: column; }
  button.ghost { height: 42px; }
  .world-confirm { flex-direction: column; align-items: stretch; }
  .world-confirm-actions { justify-content: flex-end; }
}
@media (max-height: 700px) {
  .card { padding-top: 24px; padding-bottom: 20px; }
  .controls { margin: 16px 0; padding: 12px 0; }
  h1 { font-size: 44px; }
}
@media (max-width: 480px) {
  .slot { width: 34px; height: 34px; }
  .slot img { width: 24px; height: 24px; }
  .slot .num { display: none; }
  #hotbar { gap: 3px; padding: 5px; }
  #hint { display: none; }
  .inv-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .inv-tip { display: none; }
}
