* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #87ceeb;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
}

canvas {
  display: block;
}

#crosshair {
  position: fixed;
  top: 50%;
  left: 50%;
  width: 18px;
  height: 18px;
  transform: translate(-50%, -50%);
  pointer-events: none;
  z-index: 5;
}

#crosshair::before,
#crosshair::after {
  content: "";
  position: absolute;
  background: rgba(255, 255, 255, 0.85);
  box-shadow: 0 0 2px rgba(0, 0, 0, 0.6);
}

#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%);
}

#hotbar {
  position: fixed;
  bottom: 22px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 8px;
  padding: 8px;
  background: rgba(0, 0, 0, 0.35);
  border-radius: 10px;
  z-index: 5;
}

.swatch {
  width: 40px;
  height: 40px;
  border-radius: 6px;
  border: 2px solid rgba(255, 255, 255, 0.4);
  position: relative;
  transition: transform 0.08s ease;
}

.swatch .key {
  position: absolute;
  top: 2px;
  left: 4px;
  font-size: 10px;
  color: rgba(255, 255, 255, 0.85);
  text-shadow: 0 0 2px rgba(0, 0, 0, 0.9);
}

.swatch.empty {
  background: rgba(255, 255, 255, 0.08);
  border-style: dashed;
}

.swatch.selected {
  border-color: #fff;
  transform: scale(1.12);
  box-shadow: 0 0 8px rgba(255, 255, 255, 0.8);
}

#blocker {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.55);
  z-index: 10;
}

#menu {
  width: min(440px, calc(100vw - 32px));
  max-height: calc(100vh - 32px);
  overflow-y: auto;
  text-align: center;
  color: #fff;
  padding: 24px 0;
}

#menu h1 {
  margin: 0 0 8px;
  font-size: 40px;
  letter-spacing: 1px;
}

#menu p {
  margin: 6px 0;
  font-size: 15px;
  opacity: 0.9;
}

#menu-world {
  font-style: italic;
}

.menu-screen {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin: 18px 0;
}

.menu-screen[hidden] {
  display: none;
}

.menu-row {
  display: flex;
  gap: 10px;
}

.menu-row button {
  flex: 1;
}

#menu button {
  font: inherit;
  font-size: 16px;
  color: #fff;
  padding: 10px 16px;
  background: rgba(255, 255, 255, 0.12);
  border: 2px solid rgba(255, 255, 255, 0.4);
  border-radius: 8px;
  cursor: pointer;
}

#menu button:hover,
#menu button:focus-visible {
  background: rgba(255, 255, 255, 0.25);
  border-color: #fff;
  outline: none;
}

#blocker.busy #menu button {
  opacity: 0.5;
  cursor: wait;
}

#menu label {
  text-align: left;
  font-size: 14px;
  opacity: 0.9;
}

.name-input {
  font: inherit;
  font-size: 16px;
  padding: 10px 12px;
  color: #222;
  border: 2px solid rgba(255, 255, 255, 0.4);
  border-radius: 8px;
}

#world-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 50vh;
  overflow-y: auto;
}

#world-list li {
  display: flex;
  gap: 8px;
}

#world-list .world-load {
  flex: 1;
  min-width: 0;
  text-align: left;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.world-actions {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

#world-list .world-actions button {
  flex: 1;
  font-size: 14px;
  padding: 6px 12px;
}

#menu .world-delete:hover,
#menu .world-delete:focus-visible,
#menu #delete-hold-button {
  background: rgba(200, 40, 30, 0.35);
  border-color: #ff8a7a;
}

#menu-delete .warning {
  color: #ffb4a8;
}

#delete-hold-button {
  position: relative;
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
}

#delete-hold-button .hold-fill {
  position: absolute;
  inset: 0;
  background: rgba(220, 50, 35, 0.85);
  transform: scaleX(0);
  transform-origin: left;
}

#delete-hold-button.holding .hold-fill {
  transform: scaleX(1);
  transition: transform var(--hold-duration) linear;
}

#delete-hold-button .hold-label {
  position: relative;
}

.world-name {
  font-weight: bold;
  overflow-wrap: anywhere;
}

.world-date {
  font-size: 13px;
  opacity: 0.8;
}

#menu-status {
  color: #ffb4a8;
}

#help {
  margin-top: 18px;
  font-size: 14px;
}
