* { box-sizing: border-box; }
html, body {
  margin: 0; height: 100%; overflow: hidden; background: #000; color: #fff;
  font-family: 'VT323', 'Courier New', monospace;
  user-select: none; -webkit-user-select: none;
}
#game { position: fixed; inset: 0; width: 100%; height: 100%; display: block; image-rendering: pixelated; }

.mc-text, #subtitle, .corner, .mc-btn, #debug, #hud-title, #item-name, .chat-line, .nametag, #click-hint {
  text-shadow: 2px 2px 0 #3f3f3f;
}

#loading {
  position: fixed; inset: 0; display: flex; align-items: center; justify-content: center;
  font-size: 28px; text-align: center; padding: 16px; background: #2b2118 linear-gradient(#3a2c20, #1d1610);
}

/* Screens by state */
#title, #hud, #pause { display: none; }
body.state-title #title { display: flex; }
body.state-playing #hud, body.state-paused #hud { display: block; }
body.state-paused #pause { display: flex; }

/* ---------- Title ---------- */
#title {
  position: fixed; inset: 0; flex-direction: column; align-items: center; justify-content: center;
  padding: 16px; gap: 10px;
  background: radial-gradient(ellipse at center, rgba(0,0,0,0) 40%, rgba(0,0,0,0.25) 100%);
}
#logo-wrap { position: relative; margin-top: -6vh; max-width: 92vw; }
#logo { display: block; width: min(860px, 92vw); image-rendering: pixelated; filter: drop-shadow(0 6px 10px rgba(0,0,0,0.35)); }
#splash {
  position: absolute; right: -2%; bottom: 0; transform-origin: center;
  color: #ffff00; font-size: clamp(16px, 2.6vw, 28px); white-space: nowrap;
  text-shadow: 2px 2px 0 #3f3f00;
  animation: splash 0.5s ease-in-out infinite alternate;
}
@keyframes splash {
  from { transform: translate(30%, 10%) rotate(-20deg) scale(1); }
  to   { transform: translate(30%, 10%) rotate(-20deg) scale(1.08); }
}
#subtitle { font-size: clamp(16px, 2vw, 24px); text-align: center; max-width: 92vw; margin: 4px 0 10px; }
.menu { display: flex; flex-direction: column; gap: 10px; width: min(400px, 92vw); }
.menu .row { display: flex; gap: 8px; }
.username-label { font-size: 20px; color: #ddd; text-shadow: 2px 2px 0 #3f3f3f; margin: 8px 0 -6px; }
.mc-input {
  font-family: inherit; font-size: 24px; color: #fff; height: 42px; width: 100%; padding: 0 10px;
  background: #000; border: 2px solid #a0a0a0; outline: none; caret-color: #fff;
}
.mc-input:focus { border-color: #fff; }
.mc-input::placeholder { color: #666; }
#username-error { color: #ff5555; font-size: 20px; min-height: 0; margin: -6px 0 -4px; text-shadow: 2px 2px 0 #3f1515; }
#username-error:empty { display: none; }
.menu .row .mc-btn { flex: 1; }
.corner { position: fixed; bottom: 6px; font-size: 18px; color: #eee; }
.corner.left { left: 8px; }
.corner.right { right: 8px; }

/* Minecraft-style button */
.mc-btn {
  font-family: inherit; font-size: 24px; color: #fff; height: 42px; width: 100%;
  background: #6e6e6e linear-gradient(#7f7f7f, #686868);
  border: 2px solid #000; cursor: pointer; padding: 0 8px;
  box-shadow: inset 2px 2px 0 #a7a7a7, inset -2px -3px 0 #4e4e4e;
  image-rendering: pixelated;
}
.mc-btn:hover {
  background: #7d86b8 linear-gradient(#8a93c9, #6c76ad); border-color: #fff;
  box-shadow: inset 2px 2px 0 #bec4ea, inset -2px -3px 0 #4f578a;
  color: #ffffa0;
}
.mc-btn:active { transform: translateY(1px); }

/* Panels */
.panel {
  position: fixed; inset: 0; display: none; align-items: center; justify-content: center;
  background: rgba(0, 0, 0, 0.6); z-index: 20; padding: 16px;
}
.panel-box, .pause-box {
  background: rgba(20, 20, 20, 0.85); border: 2px solid #000; box-shadow: inset 0 0 0 2px #555;
  padding: 20px 24px; width: min(460px, 100%); font-size: 21px; text-shadow: 2px 2px 0 #3f3f3f;
}
.panel-box h2, .pause-box h2 { margin: 0 0 12px; font-weight: normal; font-size: 30px; text-align: center; }
.panel-box table { width: 100%; border-collapse: collapse; margin-bottom: 8px; }
.panel-box td { padding: 1px 4px; }
.panel-box td:first-child { color: #ffff55; white-space: nowrap; width: 40%; }
.panel-box p { margin: 6px 0 12px; }
.gray { color: #aaa; }
.yellow { color: #ffff55; }

/* ---------- Pause ---------- */
#pause { position: fixed; inset: 0; align-items: center; justify-content: center; background: rgba(0,0,0,0.5); z-index: 15; padding: 16px; }
.pause-box { background: none; border: none; box-shadow: none; display: flex; flex-direction: column; gap: 10px; width: min(400px, 100%); }

/* ---------- HUD ---------- */
#hud { position: fixed; inset: 0; pointer-events: none; }
#hud-title { position: absolute; top: 6px; left: 50%; transform: translateX(-50%); font-size: 26px; color: #fff; letter-spacing: 1px; }
#debug { position: absolute; top: 6px; left: 8px; margin: 0; font-family: inherit; font-size: 20px; line-height: 1.05; background: rgba(0,0,0,0.25); padding: 2px 6px; }
#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: #fff; }
#crosshair::before { left: 10px; top: 0; width: 2px; height: 22px; }
#crosshair::after { left: 0; top: 10px; width: 22px; height: 2px; }

#hotbar {
  position: absolute; bottom: 6px; left: 50%; transform: translateX(-50%);
  display: flex; background: rgba(0,0,0,0.45); border: 3px solid #222; box-shadow: inset 0 0 0 2px #8b8b8b;
  padding: 3px;
}
.slot { position: relative; width: 52px; height: 52px; border: 2px solid #6b6b6b; display: flex; align-items: center; justify-content: center; }
.slot canvas { width: 40px; height: 40px; image-rendering: pixelated; }
.slot.selected { outline: 4px solid #fff; outline-offset: -2px; z-index: 1; box-shadow: 0 0 0 2px #000; }
.slot-num { position: absolute; right: 3px; bottom: 0; font-size: 16px; color: #ddd; text-shadow: 1px 1px 0 #000; }
#item-name { position: absolute; bottom: 74px; left: 50%; transform: translateX(-50%); font-size: 24px; opacity: 0; white-space: nowrap; }

#chat { position: absolute; left: 6px; bottom: 80px; width: min(520px, 70vw); }
#chat-log { display: flex; flex-direction: column; justify-content: flex-end; max-height: 40vh; overflow: hidden; }
.chat-line { font-size: 21px; background: rgba(0,0,0,0.4); padding: 0 6px; line-height: 1.15; word-wrap: break-word; }
#chat-input {
  display: none; width: 100%; margin-top: 4px; font-family: inherit; font-size: 21px; color: #fff;
  background: rgba(0,0,0,0.55); border: none; outline: none; padding: 3px 6px; pointer-events: auto;
}
body.chat-open #chat-input { display: block; }
body.chat-open #chat-log { overflow-y: auto; pointer-events: auto; }

#player-list {
  display: none; position: absolute; top: 40px; left: 50%; transform: translateX(-50%);
  background: rgba(0,0,0,0.55); padding: 6px 10px; min-width: 280px; font-size: 21px;
}
.pl-head { text-align: center; color: #ffff55; margin-bottom: 4px; }
.pl-row { display: flex; justify-content: space-between; gap: 24px; background: rgba(255,255,255,0.08); margin: 2px 0; padding: 0 6px; }
.ping { color: #5f5; letter-spacing: -2px; }

#underwater { display: none; position: absolute; inset: 0; background: rgba(20, 50, 140, 0.25); }
#click-hint {
  display: none; position: absolute; left: 50%; top: 60%; transform: translateX(-50%);
  font-size: 26px; background: rgba(0,0,0,0.5); padding: 6px 14px; pointer-events: auto; cursor: pointer;
}

/* Nametags */
#nametags { position: fixed; inset: 0; pointer-events: none; overflow: hidden; }
body.state-title #nametags { display: none; }
.nametag {
  position: absolute; left: 0; top: 0; white-space: nowrap; font-size: 22px; padding: 0 5px;
  background: rgba(0,0,0,0.35); color: #fff; transform-origin: 0 0; will-change: transform;
}

@media (max-width: 640px) {
  .slot { width: 34px; height: 34px; }
  .slot canvas { width: 26px; height: 26px; }
  .slot-num { display: none; }
}

/* Dev tools only show when running locally (see isDevHost in main.js). */
.dev-only { display: none; }
html.dev .dev-only { display: block; }
