* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: #000;
  font-family: "Microsoft YaHei", "PingFang SC", system-ui, sans-serif;
  color: #fff;
  user-select: none;
}

#game {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  image-rendering: pixelated;
}

.hidden {
  display: none !important;
}

/* ---------- HUD ---------- */

#hud {
  position: fixed;
  inset: 0;
  pointer-events: none;
}

#crosshair {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 20px;
  height: 20px;
  transform: translate(-50%, -50%);
  mix-blend-mode: difference;
}
#crosshair::before,
#crosshair::after {
  content: "";
  position: absolute;
  background: #fff;
}
#crosshair::before {
  left: 9px;
  top: 0;
  width: 2px;
  height: 20px;
}
#crosshair::after {
  top: 9px;
  left: 0;
  width: 20px;
  height: 2px;
}

#water-overlay {
  position: absolute;
  inset: 0;
  background: rgba(20, 60, 160, 0.28);
}

#debug {
  position: absolute;
  left: 8px;
  top: 8px;
  margin: 0;
  padding: 6px 10px;
  background: rgba(0, 0, 0, 0.45);
  font: 13px/1.5 Consolas, "Microsoft YaHei", monospace;
  white-space: pre;
}

#toast {
  position: absolute;
  left: 50%;
  bottom: 96px;
  transform: translateX(-50%);
  padding: 4px 12px;
  background: rgba(0, 0, 0, 0.5);
  border-radius: 4px;
  font-size: 15px;
  opacity: 0;
  transition: opacity 0.25s;
}
#toast.show {
  opacity: 1;
}

#hotbar {
  position: absolute;
  left: 50%;
  bottom: 12px;
  transform: translateX(-50%);
  display: flex;
  gap: 2px;
  padding: 3px;
  background: rgba(0, 0, 0, 0.45);
  border: 2px solid rgba(0, 0, 0, 0.6);
}

.slot {
  position: relative;
  width: 52px;
  height: 52px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 3px solid rgba(140, 140, 140, 0.55);
  background: rgba(60, 60, 60, 0.4);
}
.slot.active {
  border-color: #fff;
  box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.6);
}
.slot img {
  width: 40px;
  height: 40px;
  image-rendering: pixelated;
}
.slot span {
  position: absolute;
  right: 3px;
  bottom: 0;
  font-size: 11px;
  text-shadow: 1px 1px 0 #000;
}

/* ---------- Screens ---------- */

.screen {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(10, 14, 24, 0.55);
  backdrop-filter: blur(2px);
}

#menu {
  background:
    linear-gradient(rgba(0, 0, 0, 0.35), rgba(0, 0, 0, 0.55)),
    repeating-linear-gradient(90deg, #5d9e34 0 32px, #57952f 32px 64px) top / 100% 40% no-repeat,
    repeating-linear-gradient(90deg, #86603f 0 32px, #7c5838 32px 64px) bottom / 100% 60% no-repeat;
}

.panel {
  width: min(520px, 92vw);
  max-height: 92vh;
  overflow-y: auto;
  padding: 24px 28px;
  background: rgba(24, 24, 28, 0.9);
  border: 3px solid #555;
  box-shadow: inset 0 0 0 3px #222, 0 10px 40px rgba(0, 0, 0, 0.5);
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.panel.wide {
  width: min(720px, 94vw);
}

h1,
h2,
h3 {
  margin: 0;
  text-shadow: 2px 2px 0 #000;
}
h1 {
  font-size: 34px;
  letter-spacing: 2px;
  color: #ffe36e;
}
h1 small {
  font-size: 16px;
  color: #ddd;
  letter-spacing: 0;
}
h3 {
  margin-top: 6px;
  font-size: 16px;
  color: #bbb;
}

.sub {
  margin: 0;
  font-size: 13px;
  color: #aaa;
}

button {
  font: inherit;
  font-size: 15px;
  color: #fff;
  padding: 8px 14px;
  background: linear-gradient(#7a7a7a, #5a5a5a);
  border: 2px solid #1e1e1e;
  box-shadow: inset 0 2px 0 rgba(255, 255, 255, 0.25), inset 0 -2px 0 rgba(0, 0, 0, 0.3);
  cursor: pointer;
  text-shadow: 1px 1px 0 #000;
}
button:hover {
  background: linear-gradient(#8e9ed8, #6676b8);
}
button.primary {
  background: linear-gradient(#5aa84a, #3d8030);
}
button.primary:hover {
  background: linear-gradient(#6cc05a, #4a963b);
}
button.danger:hover {
  background: linear-gradient(#d06060, #a03c3c);
}

input:not([type="range"]) {
  font: inherit;
  font-size: 15px;
  padding: 8px 10px;
  color: #fff;
  background: #000;
  border: 2px solid #777;
  outline: none;
  user-select: text;
}
input:not([type="range"]):focus {
  border-color: #ccc;
}

#new-player {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
#new-player button {
  grid-column: 1 / -1;
}

#player-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 34vh;
  overflow-y: auto;
}
.player-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.1);
}
.player-row .info {
  flex: 1;
  min-width: 0;
}
.player-row .name {
  font-size: 16px;
  font-weight: bold;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.player-row .meta {
  font-size: 12px;
  color: #999;
}
.empty {
  margin: 0;
  color: #999;
  font-size: 14px;
}

.help {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 12px;
  margin-top: 4px;
  padding-top: 10px;
  border-top: 1px solid #333;
  font-size: 12px;
  color: #aaa;
}
.help b {
  width: 100%;
  color: #ddd;
}

label {
  display: grid;
  grid-template-columns: 90px 1fr 64px;
  align-items: center;
  gap: 8px;
  font-size: 14px;
}
label output {
  text-align: right;
  color: #ccc;
}

.row {
  display: flex;
  gap: 8px;
}
.row button {
  flex: 1;
}

.hint {
  margin: 0;
  min-height: 1em;
  font-size: 13px;
  color: #ffd76a;
}

#inv-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(84px, 1fr));
  gap: 6px;
}
.inv-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 8px 4px;
  font-size: 12px;
  background: rgba(255, 255, 255, 0.06);
}
.inv-item img {
  width: 44px;
  height: 44px;
  image-rendering: pixelated;
}

#error-msg {
  color: #f88;
}
