/* 블록숲 — UI 스타일 */
* { margin: 0; padding: 0; box-sizing: border-box; }

html, body {
  width: 100%; height: 100%;
  overflow: hidden;
  background: #000;
  font-family: 'Malgun Gothic', '맑은 고딕', 'Segoe UI', system-ui, sans-serif;
  user-select: none;
  -webkit-user-select: none;
}

#game {
  position: absolute;
  inset: 0;
  width: 100%; height: 100%;
  display: block;
  cursor: default;
}

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

#crosshair {
  position: absolute;
  left: 50%; top: 50%;
  width: 22px; height: 22px;
  transform: translate(-50%, -50%);
  mix-blend-mode: difference;
}
#crosshair::before, #crosshair::after {
  content: '';
  position: absolute;
  background: #ddd;
}
#crosshair::before { left: 50%; top: 0; width: 2px; height: 100%; transform: translateX(-50%); }
#crosshair::after { top: 50%; left: 0; height: 2px; width: 100%; transform: translateY(-50%); }

#vignette {
  position: absolute; inset: 0;
  background: radial-gradient(ellipse at center, transparent 62%, rgba(0,0,0,0.28) 100%);
}

#underwater-overlay {
  position: absolute; inset: 0;
  background: rgba(28, 70, 160, 0.22);
}

#hotbar {
  position: absolute;
  left: 50%; bottom: 12px;
  transform: translateX(-50%);
  display: flex;
  gap: 4px;
  padding: 4px;
  background: rgba(0, 0, 0, 0.45);
  border: 2px solid rgba(0, 0, 0, 0.65);
  border-radius: 4px;
}
.slot {
  position: relative;
  width: 52px; height: 52px;
  background: rgba(60, 60, 60, 0.7);
  border: 2px solid #1a1a1a;
  box-shadow: inset 1px 1px 0 rgba(255,255,255,0.18), inset -1px -1px 0 rgba(0,0,0,0.4);
  display: flex; align-items: center; justify-content: center;
}
.slot.selected {
  border-color: #fff;
  box-shadow: 0 0 0 2px rgba(255,255,255,0.85), inset 0 0 6px rgba(255,255,255,0.25);
}
.slot canvas { width: 44px; height: 44px; image-rendering: pixelated; }
.slot-num {
  position: absolute;
  left: 3px; top: 1px;
  font-size: 10px;
  color: rgba(255,255,255,0.75);
  text-shadow: 1px 1px 0 #000;
}

#item-name {
  position: absolute;
  left: 50%; bottom: 84px;
  transform: translateX(-50%);
  color: #fff;
  font-size: 17px;
  font-weight: bold;
  text-shadow: 2px 2px 0 rgba(0,0,0,0.7);
  opacity: 0;
  transition: opacity 0.4s;
}
#item-name.show { opacity: 1; }

#debug {
  position: absolute;
  left: 8px; top: 8px;
  padding: 8px 10px;
  background: rgba(0, 0, 0, 0.5);
  color: #e6e6e6;
  font-family: Consolas, monospace;
  font-size: 13px;
  line-height: 1.5;
  white-space: pre;
  border-radius: 3px;
}

#toast {
  position: absolute;
  left: 50%; bottom: 130px;
  transform: translateX(-50%);
  padding: 8px 18px;
  background: rgba(0, 0, 0, 0.72);
  color: #ffe98a;
  font-size: 15px;
  font-weight: bold;
  border-radius: 4px;
  opacity: 0;
  transition: opacity 0.3s;
  pointer-events: none;
}
#toast.show { opacity: 1; }

#help-hint {
  position: absolute;
  right: 10px; bottom: 10px;
  color: rgba(255,255,255,0.55);
  font-size: 12px;
  text-shadow: 1px 1px 0 rgba(0,0,0,0.8);
}

/* ---------- 공용 패널/버튼 ---------- */
.panel {
  background: rgba(22, 22, 24, 0.92);
  border: 2px solid #000;
  box-shadow: inset 1px 1px 0 rgba(255,255,255,0.12), 0 10px 40px rgba(0,0,0,0.6);
  border-radius: 6px;
  padding: 26px 34px;
  color: #eee;
  text-align: center;
  max-width: min(92vw, 560px);
  max-height: 88vh;
  overflow-y: auto;
}
.panel h2 { margin-bottom: 16px; font-size: 24px; text-shadow: 2px 2px 0 #000; }

.mc-btn {
  display: block;
  width: 300px;
  max-width: 80vw;
  margin: 8px auto;
  padding: 12px 0;
  font-size: 17px;
  font-weight: bold;
  font-family: inherit;
  color: #fff;
  text-shadow: 2px 2px 0 rgba(0,0,0,0.6);
  background: linear-gradient(#8d8d8d, #6f6f6f 45%, #5a5a5a);
  border: 2px solid #000;
  box-shadow: inset 2px 2px 0 rgba(255,255,255,0.35), inset -2px -2px 0 rgba(0,0,0,0.35);
  cursor: pointer;
}
.mc-btn:hover {
  background: linear-gradient(#a0b8e8, #7d97cf 45%, #6a83bb);
  border-color: #fff;
}
.mc-btn:active { transform: translateY(1px); }
.mc-btn.small { width: 230px; padding: 9px 0; font-size: 15px; }
.mc-btn.danger { background: linear-gradient(#d86a5a, #b84a3a 45%, #9c3a2c); }

.mc-select {
  font-family: inherit;
  font-size: 14px;
  padding: 6px 10px;
  background: #444;
  color: #fff;
  border: 2px solid #000;
}

.row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin: 10px 0;
  font-size: 15px;
}

/* ---------- 타이틀 ---------- */
#title-screen {
  position: absolute; inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: radial-gradient(ellipse at center, rgba(0,0,0,0.15) 0%, rgba(0,0,0,0.55) 100%);
}
.title-inner { text-align: center; }
.logo {
  font-size: clamp(64px, 12vw, 130px);
  font-weight: 900;
  letter-spacing: 0.06em;
  color: #fff;
  text-shadow:
    3px 3px 0 #3e7a24,
    6px 6px 0 #2c5717,
    9px 9px 0 rgba(0,0,0,0.45),
    0 0 40px rgba(120, 200, 90, 0.35);
}
.subtitle {
  margin-top: 2px;
  color: #cfe8bd;
  font-size: clamp(12px, 2vw, 18px);
  letter-spacing: 0.4em;
  text-shadow: 2px 2px 0 rgba(0,0,0,0.7);
}
.splash {
  display: inline-block;
  margin-top: 14px;
  color: #ffff55;
  font-size: 18px;
  font-weight: bold;
  text-shadow: 2px 2px 0 rgba(0,0,0,0.7);
  transform: rotate(-6deg);
  animation: splashPulse 0.9s ease-in-out infinite alternate;
}
@keyframes splashPulse {
  from { transform: rotate(-6deg) scale(1); }
  to { transform: rotate(-6deg) scale(1.08); }
}
.menu { margin-top: 34px; }
.note {
  margin-top: 26px;
  color: rgba(255,255,255,0.82);
  font-size: 13.5px;
  line-height: 1.7;
  text-shadow: 1px 1px 0 rgba(0,0,0,0.8);
}
.version {
  position: absolute;
  left: 10px; bottom: 8px;
  color: rgba(255,255,255,0.5);
  font-size: 12px;
  text-shadow: 1px 1px 0 #000;
}

/* ---------- 일시정지/오류 ---------- */
#pause-screen, #error-screen {
  position: absolute; inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.45);
}
.controls-help {
  margin-top: 16px;
  font-size: 13px;
  line-height: 1.8;
  color: #c8c8c8;
}
.controls-help b { color: #ffe98a; }
.seed {
  margin-top: 12px;
  font-size: 12px;
  color: #8a8a8a;
  font-family: Consolas, monospace;
}
#error-msg { color: #ff9c8a; margin: 10px 0; }

/* ---------- 팔레트 ---------- */
#palette {
  position: absolute; inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.35);
  z-index: 10;
}
.palette-tip { font-size: 13px; color: #a8a8a8; margin-bottom: 14px; }
#palette-grid {
  display: grid;
  grid-template-columns: repeat(7, 64px);
  gap: 6px;
  justify-content: center;
}
.pal-item {
  width: 64px; height: 76px;
  background: rgba(70, 70, 70, 0.75);
  border: 2px solid #1a1a1a;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  cursor: pointer;
  box-shadow: inset 1px 1px 0 rgba(255,255,255,0.15);
}
.pal-item:hover, .pal-item.hover {
  border-color: #fff;
  background: rgba(110, 110, 110, 0.85);
}
.pal-item canvas { width: 40px; height: 40px; image-rendering: pixelated; pointer-events: none; }
.pal-item span {
  font-size: 10.5px;
  color: #eee;
  text-shadow: 1px 1px 0 #000;
  pointer-events: none;
  white-space: nowrap;
}

#vcursor {
  position: absolute;
  width: 0; height: 0;
  z-index: 20;
  pointer-events: none;
}
#vcursor::after {
  content: '';
  position: absolute;
  left: 0; top: 0;
  width: 0; height: 0;
  border-left: 12px solid #fff;
  border-bottom: 12px solid transparent;
  border-right: 5px solid transparent;
  filter: drop-shadow(1px 1px 1px rgba(0,0,0,0.9));
}

@media (max-width: 620px) {
  #palette-grid { grid-template-columns: repeat(4, 64px); }
}

/* ---------- 협업/캐릭터 UI ---------- */
#nickname, #roompass {
  display: block;
  width: 300px;
  max-width: 80vw;
  margin: 0 auto 12px;
  padding: 10px 12px;
  font-family: inherit;
  font-size: 15px;
  text-align: center;
  background: rgba(0, 0, 0, 0.55);
  color: #fff;
  border: 2px solid #000;
  box-shadow: inset 2px 2px 0 rgba(0,0,0,0.5);
  outline: none;
}
#nickname:focus, #roompass:focus { border-color: #fff; }
#nickname::placeholder, #roompass::placeholder { color: rgba(255,255,255,0.45); }

.mc-btn.collab {
  background: linear-gradient(#6fbf5a, #4f9c3e 45%, #3d7d2f);
}
.mc-btn.collab:hover { background: linear-gradient(#87d970, #61b34e 45%, #4c9440); border-color: #fff; }
.mc-btn.collab:disabled {
  background: #555;
  color: #999;
  cursor: not-allowed;
  border-color: #333;
}

.collab-note {
  margin-top: 6px;
  font-size: 12.5px;
  color: #b9e8a6;
  text-shadow: 1px 1px 0 rgba(0,0,0,0.8);
  line-height: 1.6;
}

.chk-label {
  font-size: 14px;
  color: #ddd;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 5px;
}
.chk-label input { width: 16px; height: 16px; accent-color: #6fbf5a; cursor: pointer; }

#online-count {
  position: absolute;
  right: 10px; top: 8px;
  padding: 5px 12px;
  background: rgba(0, 0, 0, 0.5);
  color: #b9e8a6;
  font-size: 13px;
  font-weight: bold;
  border-radius: 3px;
  text-shadow: 1px 1px 0 #000;
}

#nametags { position: absolute; inset: 0; overflow: hidden; pointer-events: none; }
.nametag {
  position: absolute;
  transform: translate(-50%, -100%);
  padding: 2px 8px;
  background: rgba(0, 0, 0, 0.45);
  color: #fff;
  font-size: 13px;
  font-weight: bold;
  border-radius: 3px;
  white-space: nowrap;
  text-shadow: 1px 1px 0 #000;
}

#chat-box {
  position: absolute;
  left: 10px; bottom: 86px;
  width: min(46vw, 440px);
  pointer-events: none;
}
#chat-messages {
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  gap: 2px;
  margin-bottom: 6px;
  max-height: 220px;
  overflow: hidden;
}
.chat-msg {
  padding: 3px 8px;
  background: rgba(0, 0, 0, 0.45);
  color: #fff;
  font-size: 13.5px;
  border-radius: 3px;
  text-shadow: 1px 1px 0 #000;
  animation: chatFade 12s forwards;
  word-break: break-all;
}
.chat-msg b { color: #ffe98a; }
.chat-msg.system { color: #b9e8a6; font-style: italic; }
@keyframes chatFade {
  0%, 75% { opacity: 1; }
  100% { opacity: 0; }
}
#chat-input {
  pointer-events: auto;
  width: 100%;
  padding: 8px 10px;
  font-family: inherit;
  font-size: 14px;
  background: rgba(0, 0, 0, 0.7);
  color: #fff;
  border: 2px solid rgba(255,255,255,0.6);
  outline: none;
}
