html,
body,
#app-root {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background-color: #121820;
  font-family: system-ui, -apple-system, "Noto Sans JP", "Hiragino Sans", "Yu Gothic", sans-serif;
}

#bevy-canvas {
  display: block;
  width: 100%;
  height: 100%;
  outline: none;
}

#loading-overlay {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(12, 18, 26, 0.92);
  color: #f0f4f8;
}

.loading-card {
  width: min(420px, 100%);
  padding: 18px 20px;
  border-radius: 8px;
  background: rgba(18, 26, 38, 0.96);
  border: 1px solid rgba(255, 255, 255, 0.16);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.45);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

#loading-overlay.is-error .loading-card {
  border-color: rgba(248, 113, 113, 0.6);
}

#loading-title {
  font-size: 16px;
  font-weight: 700;
}

#loading-status {
  font-size: 13px;
  line-height: 1.45;
  color: #cbd5e1;
}

#loading-progress {
  appearance: none;
  border: 0 solid;
  overflow: clip;
  container-type: inline-size;
  inline-size: 100%;
  block-size: 8px;
  --progress-bar-radius: 1e5px;
  --progress-bar-track: rgba(255, 255, 255, 0.14);
  --progress-bar-fill: #60a5fa;
  --progress-bar-indeterminate-size: 30%;
  --progress-bar-indeterminate-animation-duration: 1.5s;
  border-radius: var(--progress-bar-radius);
  background: var(--progress-bar-track);
  box-shadow: inset 0 1px 2px rgb(0 0 0 / 0.25);
}

@media (prefers-reduced-motion: reduce) {
  #loading-progress {
    --progress-bar-indeterminate-animation-duration: 10s;
  }
}

#loading-progress:indeterminate {
  --progress-bar-animation: progress-bar-indeterminate var(--progress-bar-indeterminate-animation-duration) infinite linear;
}

#loading-progress::-webkit-progress-bar {
  background: transparent;
}

#loading-progress::-webkit-progress-value {
  background: var(--progress-bar-fill);
  border-radius: var(--progress-bar-radius);
  transition: inline-size 0.2s;
  animation: var(--progress-bar-animation, revert-rule);
}

#loading-progress::-moz-progress-bar {
  background: var(--progress-bar-fill);
  border-radius: var(--progress-bar-radius);
  transition: inline-size 0.2s;
  animation: var(--progress-bar-animation, revert-rule);
}

@keyframes progress-bar-indeterminate {
  from,
  to {
    inline-size: var(--progress-bar-indeterminate-size);
    margin-right: auto;
  }
  from {
    translate: -100%;
  }
  to {
    translate: 100cqi;
  }
}

#btn-loading-reload {
  align-self: flex-start;
  padding: 5px 12px;
}

#perf-badge {
  position: fixed;
  top: 76px;
  right: 8px;
  padding: 4px 8px;
  font-family: ui-monospace, "Cascadia Mono", "Noto Sans Mono CJK JP", monospace;
  font-size: 11px;
  color: #a7f3d0;
  pointer-events: none;
}

#hud-overlay[hidden],
#perf-badge[hidden],
#loading-progress[hidden],
#btn-loading-reload[hidden],
#hud-chat[hidden],
#hud-right[hidden],
#hud-detail[hidden] {
  display: none;
}

#hud-overlay {
  position: fixed;
  inset: 0;
  z-index: 10;
  pointer-events: none;
  user-select: none;
  color: #edf2f7;
}

#crosshair {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 20px;
  font-weight: 700;
  line-height: 1;
  color: rgba(255, 255, 255, 0.6);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.85);
}

#crosshair.locked {
  color: rgba(255, 255, 255, 0.95);
}

.hud-panel {
  pointer-events: auto;
  background: rgba(10, 14, 20, 0.74);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 6px;
  backdrop-filter: blur(2px);
}

#hud-top {
  position: fixed;
  top: 8px;
  left: 8px;
  right: 8px;
  padding: 6px 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.hud-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
}

.hud-coords {
  font-family: ui-monospace, "Cascadia Mono", "Noto Sans Mono CJK JP", monospace;
  font-size: 16px;
  font-weight: 700;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.9);
  display: flex;
  align-items: baseline;
  gap: 6px;
  flex-wrap: wrap;
}

.mode-feet {
  color: #b8e1ff;
}

.mode-target {
  color: #ffd166;
}

.coord-abs {
  color: #f0d78c;
}

.coord-abs.target-active {
  color: #ffb703;
}

.coord-rel {
  color: #f0a8d0;
}

.coord-sep {
  color: #9aa5b1;
}

.hud-meta {
  font-size: 12px;
  color: #d8e2ec;
}

.hud-actions {
  display: flex;
  align-items: center;
  gap: 4px;
}

button {
  appearance: none;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 4px;
  background: rgba(34, 44, 58, 0.9);
  color: #f4f7fa;
  font-family: inherit;
  font-size: 12px;
  padding: 3px 8px;
  cursor: pointer;
  white-space: nowrap;
}

button:hover:not(:disabled) {
  background: rgba(56, 72, 94, 0.95);
}

button:disabled {
  opacity: 0.45;
  cursor: default;
}

#hud-chat {
  position: fixed;
  left: 8px;
  bottom: 8px;
  width: 360px;
  max-width: calc(100vw - 298px);
  padding: 6px 8px;
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.chat-title {
  font-size: 12px;
  font-weight: 600;
  color: #e2e8f0;
}

.chat-log {
  height: 118px;
  overflow-y: auto;
  padding: 4px 6px;
  border-radius: 4px;
  background: rgba(6, 9, 14, 0.65);
  border: 1px solid rgba(255, 255, 255, 0.08);
  font-size: 12px;
  line-height: 1.38;
  user-select: text;
}

.chat-line {
  word-break: break-word;
  color: #f1f5f9;
}

.chat-input-row {
  display: flex;
  align-items: center;
  gap: 4px;
}

#chat-input {
  flex: 1 1 auto;
  min-width: 80px;
  padding: 4px 6px;
  border-radius: 4px;
  border: 1px solid rgba(255, 255, 255, 0.25);
  background: rgba(16, 22, 31, 0.92);
  color: #f8fafc;
  font-family: inherit;
  font-size: 12px;
  outline: none;
}

#chat-input:focus {
  border-color: #60a5fa;
}

#hud-right {
  position: fixed;
  right: 8px;
  bottom: 8px;
  width: 274px;
  padding: 6px 8px;
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.plot-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px;
}

.utility-row {
  gap: 4px;
}

.grow-btn {
  flex: 1 1 auto;
}

.key-hints {
  font-size: 11px;
  line-height: 1.35;
  color: #cbd5e1;
}

@media (max-width: 760px) {
  .hud-coords {
    font-size: 13px;
    gap: 4px;
  }

  button {
    font-size: 11px;
    padding: 2px 6px;
  }

  #hud-right {
    width: 214px;
    padding: 5px 6px;
  }

  #hud-chat {
    width: calc(100vw - 238px);
    max-width: 340px;
    min-width: 190px;
    padding: 5px 6px;
  }

  .chat-log {
    height: 92px;
    font-size: 11px;
  }

  #chat-input {
    font-size: 11px;
    padding: 3px 5px;
  }

  .key-hints {
    font-size: 10px;
  }
}
